u3d 1.0.8 → 1.0.9

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: 71adab2b2a03a3bc2b9d6af6dd6dd42cc02114d9
4
- data.tar.gz: cb3f2acc27496edbf00ac8a2c5e942576ddb01f6
3
+ metadata.gz: 7ef51a1704cb01f95cc2ff2f66f90eb851c0010d
4
+ data.tar.gz: 26d03be1911d01506a9aa0bab60caf1abd8cf07d
5
5
  SHA512:
6
- metadata.gz: 482ad130cd557980293b600ff3b19818b28441705f99e5b17244bb6638c44a1ace808fdfd83798656b96644a3a8c86faca70ebb9acd27eaa797a72bface947aa
7
- data.tar.gz: f19eae468d593e8ab1e64c4ce1224773e963c9020f09fd0857e59b9e5029ad83f63eb393372e59ff6a5195ceb5e3932c4310958d4e5e66b8060f4f32f3999777
6
+ metadata.gz: 18d24c1137ce676f44354019fe449180038fde137cfdb6b7c8a94a4ce3639cf93ae2fda3d114c06ac97ef2d4579e26cf619f2658cf679d3ff9b3464faae72bff
7
+ data.tar.gz: 8f2c047324246b81c7ac78325045d49bbb90d867c4c345b90687b36aa2e62c1a1f7c41ac16c18476806943ecc1c95ec9d2f36909ebb916771119a581e2c01d31
@@ -1,4 +1,4 @@
1
- future-release=v1.0.8
1
+ future-release=v1.0.9
2
2
  since-tag=v0.9
3
3
  exclude_tags_regex=v0\.[0-8]\..*
4
4
  exclude-labels=nochangelog
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## [v1.0.9](https://github.com/DragonBox/u3d/tree/v1.0.9) (2017-10-31)
4
+ [Full Changelog](https://github.com/DragonBox/u3d/compare/v1.0.8...v1.0.9)
5
+
6
+ **Implemented enhancements:**
7
+
8
+ - Implement uninstall [\#174](https://github.com/DragonBox/u3d/issues/174)
9
+ - u3d/install: find all patched versions [\#172](https://github.com/DragonBox/u3d/issues/172)
10
+
11
+ **Merged pull requests:**
12
+
13
+ - u3d/available: discover all patched releases \(fixes \#172\) [\#173](https://github.com/DragonBox/u3d/pull/173) ([lacostej](https://github.com/lacostej))
14
+ - Implement uninstall. Also modify the output of list on Mac and deprecate Installation.path in favor of Installation.root\_path [\#171](https://github.com/DragonBox/u3d/pull/171) ([lacostej](https://github.com/lacostej))
15
+ - u3d/cleanups small refactorings and cleanups [\#170](https://github.com/DragonBox/u3d/pull/170) ([lacostej](https://github.com/lacostej))
16
+
3
17
  ## [v1.0.8](https://github.com/DragonBox/u3d/tree/v1.0.8) (2017-10-18)
4
18
  [Full Changelog](https://github.com/DragonBox/u3d/compare/v1.0.7...v1.0.8)
5
19
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- u3d (1.0.8)
4
+ u3d (1.0.9)
5
5
  colored (>= 1.2, < 2.0.0)
6
6
  commander (>= 4.4.0, < 5.0.0)
7
7
  file-tail (>= 1.2.0)
data/README.md CHANGED
@@ -25,6 +25,10 @@ Available commands are:
25
25
 
26
26
  ![u3d install](https://github.com/DragonBox/u3d/raw/master/docs/assets/u3d_install.png)
27
27
 
28
+ * `u3d uninstall`: Uninstall Unity3D versions
29
+
30
+ ![u3d uninstall](https://github.com/DragonBox/u3d/raw/master/docs/assets/u3d_uninstall.png)
31
+
28
32
  * `u3d list`: List installed versions of Unity3d
29
33
 
30
34
  ![u3d list](https://github.com/DragonBox/u3d/raw/master/docs/assets/u3d_list.png)
Binary file
Binary file
Binary file
File without changes
data/exe/u3d CHANGED
File without changes
data/lib/u3d/commands.rb CHANGED
@@ -53,7 +53,7 @@ module U3d
53
53
  sorted_keys = vcomparators.sort.map { |v| v.version.to_s }
54
54
  sorted_keys.each do |k|
55
55
  u = map[k]
56
- UI.message "Version #{u.version.ljust(30)}(#{u.path})"
56
+ UI.message "Version #{u.version.ljust(30)}(#{u.root_path})"
57
57
  packages = u.packages
58
58
  next unless options[:packages] && packages && !packages.empty?
59
59
  UI.message 'Packages:'
@@ -126,11 +126,7 @@ module U3d
126
126
 
127
127
  verify_package_names(definition, packages)
128
128
 
129
- if options[:install]
130
- U3dCore::Globals.use_keychain = true if options[:keychain] && Helper.mac?
131
- UI.important 'Root privileges are required'
132
- raise 'Could not get administrative privileges' unless U3dCore::CommandExecutor.has_admin_privileges?
133
- end
129
+ get_administrative_privileges(options) if options[:install]
134
130
 
135
131
  files = Downloader.fetch_modules(definition, packages: packages, download: options[:download])
136
132
 
@@ -138,6 +134,20 @@ module U3d
138
134
  Installer.install_modules(files, definition.version, installation_path: options[:installation_path])
139
135
  end
140
136
 
137
+ def uninstall(args: [], options: [])
138
+ version = specified_or_current_project_version(args[0])
139
+
140
+ unity = check_unity_presence(version: version)
141
+
142
+ unless unity
143
+ UI.user_error!('Unity version #{version} is not present and cannot be uninstalled')
144
+ end
145
+
146
+ get_administrative_privileges(options)
147
+
148
+ Installer.uninstall(unity: unity)
149
+ end
150
+
141
151
  def install_dependencies
142
152
  unless Helper.linux?
143
153
  UI.important 'u3d dependencies is Linux-only, and not needed on other OS'
@@ -168,8 +178,7 @@ module U3d
168
178
  run_args = [extra_run_args, run_args].flatten
169
179
  end
170
180
 
171
- # we could support matching 5.3.6p3 if passed 5.3.6
172
- unity = Installer.create.installed.find { |u| u.version == version }
181
+ unity = check_unity_presence(version: version)
173
182
  UI.user_error! "Unity version '#{version}' not found" unless unity
174
183
  runner.run(unity, run_args, raw_logs: options[:raw_logs])
175
184
  end
@@ -290,12 +299,13 @@ module U3d
290
299
  end
291
300
 
292
301
  def check_unity_presence(version: nil)
302
+ # idea: we could support matching 5.3.6p3 if passed 5.3.6
293
303
  installed = Installer.create.installed
294
304
  unity = installed.find { |u| u.version == version }
295
305
  if unity.nil?
296
306
  UI.verbose "Version #{version} of Unity is not installed yet"
297
307
  else
298
- UI.verbose "Unity #{version} is installed at #{unity.path}"
308
+ UI.verbose "Unity #{version} is installed at #{unity.root_path}"
299
309
  return unity
300
310
  end
301
311
  nil
@@ -312,7 +322,7 @@ module U3d
312
322
  packages.delete('Unity')
313
323
 
314
324
  # FIXME: Move me to the WindowsInstaller
315
- options[:installation_path] ||= unity.path if definition.os == :win
325
+ options[:installation_path] ||= unity.root_path if definition.os == :win
316
326
  end
317
327
  if unity.packages
318
328
  unity.packages.each do |pack|
@@ -328,6 +338,12 @@ module U3d
328
338
  end
329
339
  true
330
340
  end
341
+
342
+ def get_administrative_privileges(options)
343
+ U3dCore::Globals.use_keychain = true if options[:keychain] && Helper.mac?
344
+ UI.important 'Root privileges are required'
345
+ raise 'Could not get administrative privileges' unless U3dCore::CommandExecutor.has_admin_privileges?
346
+ end
331
347
  end
332
348
  end
333
349
  # rubocop:enable ClassLength
@@ -148,6 +148,16 @@ This command allows you to either:
148
148
  end
149
149
  end
150
150
 
151
+ command :uninstall do |c|
152
+ c.syntax = 'u3d uninstall [<version>]'
153
+ c.description = "Uninstall the specified Unity3d version."
154
+ c.option '-k', '--keychain', 'Gain privileges right through the keychain. [OSX only]'
155
+ c.example 'Uninstall Unity version 5.2.1f1', 'u3d uninstall 5.1.2f1'
156
+ c.action do |args, options|
157
+ Commands.uninstall(args: args, options: convert_options(options))
158
+ end
159
+ end
160
+
151
161
  command :dependencies do |c|
152
162
  c.syntax = 'u3d dependencies'
153
163
  c.summary = 'Installs Unity dependencies. [Linux only]'
@@ -1,170 +1,181 @@
1
- ## --- BEGIN LICENSE BLOCK ---
2
- # Copyright (c) 2016-present WeWantToKnow AS
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in all
12
- # copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
- # SOFTWARE.
21
- ## --- END LICENSE BLOCK ---
22
-
23
- require 'u3d/utils'
24
-
25
- module U3d
26
- UNITY_DIR_CHECK = /Unity_\d+\.\d+\.\d+[a-z]\d+/
27
- UNITY_DIR_CHECK_LINUX = /unity-editor-\d+\.\d+\.\d+[a-z]\d+\z/
28
-
29
- class Installation
30
- def self.create(path: nil)
31
- if Helper.mac?
32
- MacInstallation.new path
33
- elsif Helper.linux?
34
- LinuxInstallation.new path
35
- else
36
- WindowsInstallation.new path
37
- end
38
- end
39
- end
40
-
41
- class MacInstallation < Installation
42
- attr_reader :path
43
-
44
- require 'plist'
45
-
46
- def initialize(path: nil)
47
- @path = path
48
- end
49
-
50
- def version
51
- plist['CFBundleVersion']
52
- end
53
-
54
- def default_log_file
55
- "#{ENV['HOME']}/Library/Logs/Unity/Editor.log"
56
- end
57
-
58
- def exe_path
59
- "#{path}/Contents/MacOS/Unity"
60
- end
61
-
62
- def packages
63
- if Utils.parse_unity_version(version)[0].to_i <= 4
64
- # Unity < 5 doesn't have packages
65
- return []
66
- end
67
- fpath = File.expand_path('../PlaybackEngines', path)
68
- return [] unless Dir.exist? fpath # install without package
69
- Dir.entries(fpath).select { |e| File.directory?(File.join(fpath, e)) && !(e == '.' || e == '..') }
70
- end
71
-
72
- def clean_install?
73
- path =~ UNITY_DIR_CHECK
74
- end
75
-
76
- private
77
-
78
- def plist
79
- @plist ||= Plist.parse_xml("#{@path}/Contents/Info.plist")
80
- end
81
- end
82
-
83
- class LinuxInstallation < Installation
84
- attr_reader :path
85
-
86
- def initialize(path: nil)
87
- @path = path
88
- end
89
-
90
- def version
91
- # I don't find an easy way to extract the version on Linux
92
- require 'rexml/document'
93
- fpath = "#{path}/Editor/Data/PlaybackEngines/LinuxStandaloneSupport/ivy.xml"
94
- raise "Couldn't find file #{fpath}" unless File.exist? fpath
95
- doc = REXML::Document.new(File.read(fpath))
96
- version = REXML::XPath.first(doc, 'ivy-module/info/@e:unityVersion').value
97
- if (m = version.match(/^(.*)x(.*)Linux$/))
98
- version = "#{m[1]}#{m[2]}"
99
- end
100
- version
101
- end
102
-
103
- def default_log_file
104
- "#{ENV['HOME']}/.config/unity3d/Editor.log"
105
- end
106
-
107
- def exe_path
108
- "#{path}/Editor/Unity"
109
- end
110
-
111
- def packages
112
- false
113
- end
114
-
115
- def clean_install?
116
- path =~ UNITY_DIR_CHECK_LINUX
117
- end
118
- end
119
-
120
- class WindowsInstallation < Installation
121
- attr_reader :path
122
-
123
- def initialize(path: nil)
124
- @path = path
125
- end
126
-
127
- def version
128
- require 'rexml/document'
129
- # For versions >= 5
130
- fpath = "#{path}/Editor/Data/PlaybackEngines/windowsstandalonesupport/ivy.xml"
131
- # For versions < 5
132
- fpath = "#{path}/Editor/Data/PlaybackEngines/wp8support/ivy.xml" unless File.exist? fpath
133
- raise "Couldn't find file #{fpath}" unless File.exist? fpath
134
- doc = REXML::Document.new(File.read(fpath))
135
- version = REXML::XPath.first(doc, 'ivy-module/info/@e:unityVersion').value
136
-
137
- version
138
- end
139
-
140
- def default_log_file
141
- if @logfile.nil?
142
- begin
143
- loc_appdata = Utils.windows_local_appdata
144
- log_dir = File.expand_path('Unity/Editor/', loc_appdata)
145
- UI.important "Log directory (#{log_dir}) does not exist" unless Dir.exist? log_dir
146
- @logfile = File.expand_path('Editor.log', log_dir)
147
- rescue RuntimeError => ex
148
- UI.error "Unable to retrieve the editor logfile: #{ex}"
149
- end
150
- end
151
- @logfile
152
- end
153
-
154
- def exe_path
155
- File.join(@path, 'Editor', 'Unity.exe')
156
- end
157
-
158
- def packages
159
- # Unity prior to Unity5 did not have package
160
- return [] if Utils.parse_unity_version(version)[0].to_i <= 4
161
- fpath = "#{path}/Editor/Data/PlaybackEngines/"
162
- return [] unless Dir.exist? fpath # install without package
163
- Dir.entries(fpath).select { |e| File.directory?(File.join(fpath, e)) && !(e == '.' || e == '..') }
164
- end
165
-
166
- def clean_install?
167
- path =~ UNITY_DIR_CHECK
168
- end
169
- end
170
- end
1
+ ## --- BEGIN LICENSE BLOCK ---
2
+ # Copyright (c) 2016-present WeWantToKnow AS
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in all
12
+ # copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ # SOFTWARE.
21
+ ## --- END LICENSE BLOCK ---
22
+
23
+ require 'u3d/utils'
24
+
25
+ module U3d
26
+ UNITY_DIR_CHECK = /Unity_\d+\.\d+\.\d+[a-z]\d+/
27
+ UNITY_DIR_CHECK_LINUX = /unity-editor-\d+\.\d+\.\d+[a-z]\d+\z/
28
+
29
+ class Installation
30
+ attr_reader :root_path
31
+
32
+ def initialize(root_path: nil, path: nil)
33
+ @root_path = root_path
34
+ @path = path
35
+ end
36
+
37
+ def self.create(root_path: nil, path: nil)
38
+ UI.deprecated("path is deprecated. Use root_path instead") unless path.nil?
39
+ if Helper.mac?
40
+ MacInstallation.new(root_path: root_path, path: path)
41
+ elsif Helper.linux?
42
+ LinuxInstallation.new(root_path: root_path, path: path)
43
+ else
44
+ WindowsInstallation.new(root_path: root_path, path: path)
45
+ end
46
+ end
47
+ end
48
+
49
+ class MacInstallation < Installation
50
+ require 'plist'
51
+
52
+ def version
53
+ plist['CFBundleVersion']
54
+ end
55
+
56
+ def default_log_file
57
+ "#{ENV['HOME']}/Library/Logs/Unity/Editor.log"
58
+ end
59
+
60
+ def exe_path
61
+ "#{root_path}/Unity.app/Contents/MacOS/Unity"
62
+ end
63
+
64
+ def path
65
+ UI.deprecated("path is deprecated. Use root_path instead")
66
+ return @path if @path
67
+ "#{@root_path}/Unity.app"
68
+ end
69
+
70
+ def packages
71
+ if Utils.parse_unity_version(version)[0].to_i <= 4
72
+ # Unity < 5 doesn't have packages
73
+ return []
74
+ end
75
+ fpath = File.expand_path('PlaybackEngines', root_path)
76
+ return [] unless Dir.exist? fpath # install without package
77
+ Dir.entries(fpath).select { |e| File.directory?(File.join(fpath, e)) && !(e == '.' || e == '..') }
78
+ end
79
+
80
+ def clean_install?
81
+ !(root_path =~ UNITY_DIR_CHECK).nil?
82
+ end
83
+
84
+ private
85
+
86
+ def plist
87
+ @plist ||=
88
+ begin
89
+ fpath = "#{root_path}/Unity.app/Contents/Info.plist"
90
+ raise "#{fpath} doesn't exist" unless File.exist? fpath
91
+ Plist.parse_xml(fpath)
92
+ end
93
+ end
94
+ end
95
+
96
+ class LinuxInstallation < Installation
97
+ def version
98
+ # I don't find an easy way to extract the version on Linux
99
+ require 'rexml/document'
100
+ fpath = "#{root_path}/Editor/Data/PlaybackEngines/LinuxStandaloneSupport/ivy.xml"
101
+ raise "Couldn't find file #{fpath}" unless File.exist? fpath
102
+ doc = REXML::Document.new(File.read(fpath))
103
+ version = REXML::XPath.first(doc, 'ivy-module/info/@e:unityVersion').value
104
+ if (m = version.match(/^(.*)x(.*)Linux$/))
105
+ version = "#{m[1]}#{m[2]}"
106
+ end
107
+ version
108
+ end
109
+
110
+ def default_log_file
111
+ "#{ENV['HOME']}/.config/unity3d/Editor.log"
112
+ end
113
+
114
+ def exe_path
115
+ "#{root_path}/Editor/Unity"
116
+ end
117
+
118
+ def path
119
+ UI.deprecated("path is deprecated. Use root_path instead")
120
+ @root_path || @path
121
+ end
122
+
123
+ def packages
124
+ false
125
+ end
126
+
127
+ def clean_install?
128
+ !(root_path =~ UNITY_DIR_CHECK_LINUX).nil?
129
+ end
130
+ end
131
+
132
+ class WindowsInstallation < Installation
133
+ def version
134
+ require 'rexml/document'
135
+ # For versions >= 5
136
+ fpath = "#{root_path}/Editor/Data/PlaybackEngines/windowsstandalonesupport/ivy.xml"
137
+ # For versions < 5
138
+ fpath = "#{root_path}/Editor/Data/PlaybackEngines/wp8support/ivy.xml" unless File.exist? fpath
139
+ raise "Couldn't find file #{fpath}" unless File.exist? fpath
140
+ doc = REXML::Document.new(File.read(fpath))
141
+ version = REXML::XPath.first(doc, 'ivy-module/info/@e:unityVersion').value
142
+
143
+ version
144
+ end
145
+
146
+ def default_log_file
147
+ if @logfile.nil?
148
+ begin
149
+ loc_appdata = Utils.windows_local_appdata
150
+ log_dir = File.expand_path('Unity/Editor/', loc_appdata)
151
+ UI.important "Log directory (#{log_dir}) does not exist" unless Dir.exist? log_dir
152
+ @logfile = File.expand_path('Editor.log', log_dir)
153
+ rescue RuntimeError => ex
154
+ UI.error "Unable to retrieve the editor logfile: #{ex}"
155
+ end
156
+ end
157
+ @logfile
158
+ end
159
+
160
+ def exe_path
161
+ File.join(@root_path, 'Editor', 'Unity.exe')
162
+ end
163
+
164
+ def path
165
+ UI.deprecated("path is deprecated. Use root_path instead")
166
+ @root_path || @path
167
+ end
168
+
169
+ def packages
170
+ # Unity prior to Unity5 did not have package
171
+ return [] if Utils.parse_unity_version(version)[0].to_i <= 4
172
+ fpath = "#{root_path}/Editor/Data/PlaybackEngines/"
173
+ return [] unless Dir.exist? fpath # install without package
174
+ Dir.entries(fpath).select { |e| File.directory?(File.join(fpath, e)) && !(e == '.' || e == '..') }
175
+ end
176
+
177
+ def clean_install?
178
+ !(root_path =~ UNITY_DIR_CHECK).nil?
179
+ end
180
+ end
181
+ end
data/lib/u3d/installer.rb CHANGED
@@ -25,6 +25,7 @@ require 'u3d_core/core_ext/string'
25
25
  require 'u3d/installation'
26
26
  require 'fileutils'
27
27
  require 'file-tail'
28
+ require 'pathname'
28
29
 
29
30
  module U3d
30
31
  DEFAULT_LINUX_INSTALL = '/opt/'.freeze
@@ -66,6 +67,11 @@ module U3d
66
67
  installer.install(file, version, installation_path: installation_path, info: info)
67
68
  end
68
69
  end
70
+
71
+ def self.uninstall(unity: nil)
72
+ installer = Installer.create
73
+ installer.uninstall(unity: unity)
74
+ end
69
75
  end
70
76
 
71
77
  class CommonInstaller
@@ -89,20 +95,18 @@ module U3d
89
95
 
90
96
  class MacInstaller
91
97
  def sanitize_install(unity, dry_run: false)
92
- source_path = File.expand_path('..', unity.path)
98
+ source_path = unity.root_path
93
99
  parent = File.expand_path('..', source_path)
94
100
  new_path = File.join(parent, UNITY_DIR % unity.version)
95
- source_path = source_path.shellescape
96
- new_path = new_path.shellescape
97
101
 
98
- command = "mv #{source_path} #{new_path}"
102
+ command = "mv #{source_path.shellescape} #{new_path.shellescape}"
99
103
 
100
104
  CommonInstaller.sanitize_install(source_path, new_path, command, dry_run: dry_run)
101
105
  end
102
106
 
103
107
  def installed
104
108
  paths = (list_installed_paths + spotlight_installed_paths).uniq
105
- versions = paths.map { |path| MacInstallation.new(path: path) }
109
+ versions = paths.map { |path| MacInstallation.new(root_path: path) }
106
110
 
107
111
  # sorting should take into account stable/patch etc
108
112
  versions.sort! { |x, y| x.version <=> y.version }
@@ -132,9 +136,9 @@ module U3d
132
136
  destination_path = File.join(target_path, 'Applications', UNITY_DIR % version)
133
137
  FileUtils.mv temp_path, destination_path
134
138
  else
135
- UI.verbose "Unity install for version #{version} found under #{unity.path}"
139
+ UI.verbose "Unity install for version #{version} found under #{unity.root_path}"
136
140
  begin
137
- path = File.expand_path('..', unity.path)
141
+ path = unity.root_path
138
142
  move_to_temp = (temp_path != path)
139
143
  if move_to_temp
140
144
  UI.verbose "Temporary switching location of #{path} to #{temp_path} for installation purpose"
@@ -151,11 +155,22 @@ module U3d
151
155
  UI.success "Successfully installed package from #{file_path}"
152
156
  end
153
157
 
158
+ def uninstall(unity: nil)
159
+ UI.verbose("Uninstalling Unity at '#{unity.root_path}'...")
160
+ command = "rm -r #{unity.root_path.argescape}"
161
+ U3dCore::CommandExecutor.execute(command: command, admin: true)
162
+ rescue => e
163
+ UI.error "Failed to uninstall unity at #{unity.path}: #{e}"
164
+ else
165
+ UI.success "Successfully uninstalled '#{unity.root_path}'"
166
+ end
167
+
154
168
  private
155
169
 
156
170
  def list_installed_paths
157
171
  find = File.join(DEFAULT_MAC_INSTALL, 'Applications', 'Unity*', 'Unity.app')
158
172
  paths = Dir[find]
173
+ paths = paths.map { |u| Pathname.new(u).parent.to_s }
159
174
  UI.verbose "Found list_installed_paths: #{paths}"
160
175
  paths
161
176
  end
@@ -173,6 +188,7 @@ module U3d
173
188
  cmd = "mdfind \"#{mdfind_args}\" 2>/dev/null"
174
189
  UI.verbose cmd
175
190
  paths = `#{cmd}`.split("\n")
191
+ paths = paths.map { |u| Pathname.new(u).parent.to_s }
176
192
  UI.verbose "Found spotlight_installed_paths: #{paths}"
177
193
  paths
178
194
  end
@@ -180,20 +196,18 @@ module U3d
180
196
 
181
197
  class LinuxInstaller
182
198
  def sanitize_install(unity, dry_run: false)
183
- source_path = File.expand_path(unity.path)
199
+ source_path = File.expand_path(unity.root_path)
184
200
  parent = File.expand_path('..', source_path)
185
201
  new_path = File.join(parent, UNITY_DIR_LINUX % unity.version)
186
- source_path = source_path.shellescape
187
- new_path = new_path.shellescape
188
202
 
189
- command = "mv #{source_path} #{new_path}"
203
+ command = "mv #{source_path.shellescape} #{new_path.shellescape}"
190
204
 
191
205
  CommonInstaller.sanitize_install(source_path, new_path, command, dry_run: dry_run)
192
206
  end
193
207
 
194
208
  def installed
195
209
  find = File.join(DEFAULT_LINUX_INSTALL, 'unity-editor-*')
196
- versions = Dir[find].map { |path| LinuxInstallation.new(path: path) }
210
+ versions = Dir[find].map { |path| LinuxInstallation.new(root_path: path) }
197
211
 
198
212
  # sorting should take into account stable/patch etc
199
213
  versions.sort! { |x, y| x.version <=> y.version }
@@ -237,27 +251,35 @@ module U3d
237
251
  else
238
252
  UI.success 'Installation successful'
239
253
  end
254
+
255
+ def uninstall(unity: nil)
256
+ UI.verbose("Uninstalling Unity at '#{unity.root_path}'...")
257
+ command = "rm -r #{unity.root_path}"
258
+ U3dCore::CommandExecutor.execute(command: command, admin: true)
259
+ rescue => e
260
+ UI.error "Failed to uninstall unity at #{unity.path}: #{e}"
261
+ else
262
+ UI.success "Successfully uninstalled '#{unity.root_path}'"
263
+ end
240
264
  end
241
265
 
242
266
  class WindowsInstaller
243
267
  def sanitize_install(unity, dry_run: false)
244
- source_path = File.expand_path(unity.path)
268
+ source_path = File.expand_path(unity.root_path)
245
269
  parent = File.expand_path('..', source_path)
246
270
  new_path = File.join(parent, UNITY_DIR % unity.version)
247
271
 
248
272
  source_path.tr!('/', '\\')
249
273
  new_path.tr!('/', '\\')
250
- source_path = source_path.argescape
251
- new_path = new_path.argescape
252
274
 
253
- command = "move #{source_path} #{new_path}"
275
+ command = "move #{source_path.argescape} #{new_path.argescape}"
254
276
 
255
277
  CommonInstaller.sanitize_install(source_path, new_path, command, dry_run: dry_run)
256
278
  end
257
279
 
258
280
  def installed
259
281
  find = File.join(DEFAULT_WINDOWS_INSTALL, 'Unity*', 'Editor', 'Uninstall.exe')
260
- versions = Dir[find].map { |path| WindowsInstallation.new(path: File.expand_path('../..', path)) }
282
+ versions = Dir[find].map { |path| WindowsInstallation.new(root_path: File.expand_path('../..', path)) }
261
283
 
262
284
  # sorting should take into account stable/patch etc
263
285
  versions.sort! { |x, y| x.version <=> y.version }
@@ -296,6 +318,18 @@ module U3d
296
318
  UI.success "Successfully installed #{info['title']}"
297
319
  end
298
320
  end
321
+
322
+ def uninstall(unity: nil)
323
+ UI.verbose("Uninstalling Unity at '#{unity.root_path}'...")
324
+ uninstall_exe = File.join(unity.root_path, 'Editor', 'Uninstall.exe')
325
+ command = "#{uninstall_exe.argescape} /S"
326
+ UI.message("Although the uninstall process completed, it takes a few seconds before the files are actually removed")
327
+ U3dCore::CommandExecutor.execute(command: command, admin: true)
328
+ rescue => e
329
+ UI.error "Failed to uninstall unity at #{unity.path}: #{e}"
330
+ else
331
+ UI.success "Successfully uninstalled '#{unity.root_path}'"
332
+ end
299
333
  end
300
334
 
301
335
  class LinuxDependencies
@@ -78,6 +78,12 @@ module U3d
78
78
  return hash
79
79
  end
80
80
 
81
+ def fetch_version_paged(url, pattern)
82
+ U3d::Utils.get_ssl(url).scan(/\?page=\d+/).map do |page|
83
+ fetch_version("#{url}#{page}", pattern)
84
+ end.reduce({}, :merge)
85
+ end
86
+
81
87
  def fetch_betas(url, pattern)
82
88
  hash = {}
83
89
  data = Utils.get_ssl(url)
@@ -221,7 +227,7 @@ module U3d
221
227
  UI.success "Found #{current.count} releases." if current.count.nonzero?
222
228
  versions = versions.merge(current)
223
229
  UI.message 'Loading Unity patch releases'
224
- current = UnityVersions.fetch_version(UNITY_PATCHES, MAC_DOWNLOAD)
230
+ current = UnityVersions.fetch_version_paged(UNITY_PATCHES, MAC_DOWNLOAD)
225
231
  UI.success "Found #{current.count} patch releases." if current.count.nonzero?
226
232
  versions = versions.merge(current)
227
233
  UI.message 'Loading Unity beta releases'
@@ -242,7 +248,7 @@ module U3d
242
248
  UI.success "Found #{current.count} releases." if current.count.nonzero?
243
249
  versions = versions.merge(current)
244
250
  UI.message 'Loading Unity patch releases'
245
- current = UnityVersions.fetch_version(UNITY_PATCHES, WIN_DOWNLOAD)
251
+ current = UnityVersions.fetch_version_paged(UNITY_PATCHES, WIN_DOWNLOAD)
246
252
  UI.success "Found #{current.count} patch releases." if current.count.nonzero?
247
253
  versions = versions.merge(current)
248
254
  UI.message 'Loading Unity beta releases'
data/lib/u3d/version.rb CHANGED
@@ -21,7 +21,7 @@
21
21
  ## --- END LICENSE BLOCK ---
22
22
 
23
23
  module U3d
24
- VERSION = '1.0.8'.freeze
24
+ VERSION = '1.0.9'.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"\
data/local_gem_install.sh CHANGED
File without changes
data/scripts/be CHANGED
File without changes
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.8
4
+ version: 1.0.9
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: 2017-10-18 00:00:00.000000000 Z
12
+ date: 2017-10-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: commander
@@ -278,6 +278,7 @@ files:
278
278
  - docs/assets/u3d_run.png
279
279
  - docs/assets/u3d_run_current.png
280
280
  - docs/assets/u3d_sanitize.png
281
+ - docs/assets/u3d_uninstall.png
281
282
  - examples/Example1/.gitignore
282
283
  - examples/Example1/Assets/Editor.meta
283
284
  - examples/Example1/Assets/Editor/EditorRun.cs
@@ -414,7 +415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
414
415
  version: '0'
415
416
  requirements: []
416
417
  rubyforge_project:
417
- rubygems_version: 2.5.2
418
+ rubygems_version: 2.6.12
418
419
  signing_key:
419
420
  specification_version: 4
420
421
  summary: U3d