lib/u3d/commands.rb in u3d-1.0.8 vs lib/u3d/commands.rb in u3d-1.0.9
- old
+ new
@@ -51,11 +51,11 @@
# sorted versions
vcomparators = map.keys.map { |k| UnityVersionComparator.new(k) }
sorted_keys = vcomparators.sort.map { |v| v.version.to_s }
sorted_keys.each do |k|
u = map[k]
- UI.message "Version #{u.version.ljust(30)}(#{u.path})"
+ UI.message "Version #{u.version.ljust(30)}(#{u.root_path})"
packages = u.packages
next unless options[:packages] && packages && !packages.empty?
UI.message 'Packages:'
packages.each { |pack| UI.message " - #{pack}" }
end
@@ -124,22 +124,32 @@
unity = check_unity_presence(version: version)
return unless enforce_setup_coherence(packages, options, unity, definition)
verify_package_names(definition, packages)
- if options[:install]
- U3dCore::Globals.use_keychain = true if options[:keychain] && Helper.mac?
- UI.important 'Root privileges are required'
- raise 'Could not get administrative privileges' unless U3dCore::CommandExecutor.has_admin_privileges?
- end
+ get_administrative_privileges(options) if options[:install]
files = Downloader.fetch_modules(definition, packages: packages, download: options[:download])
return unless options[:install]
Installer.install_modules(files, definition.version, installation_path: options[:installation_path])
end
+ def uninstall(args: [], options: [])
+ version = specified_or_current_project_version(args[0])
+
+ unity = check_unity_presence(version: version)
+
+ unless unity
+ UI.user_error!('Unity version #{version} is not present and cannot be uninstalled')
+ end
+
+ get_administrative_privileges(options)
+
+ Installer.uninstall(unity: unity)
+ end
+
def install_dependencies
unless Helper.linux?
UI.important 'u3d dependencies is Linux-only, and not needed on other OS'
return
end
@@ -166,12 +176,11 @@
if up.exist? && args_pp.nil?
extra_run_args = ['-projectpath', up.path]
run_args = [extra_run_args, run_args].flatten
end
- # we could support matching 5.3.6p3 if passed 5.3.6
- unity = Installer.create.installed.find { |u| u.version == version }
+ unity = check_unity_presence(version: version)
UI.user_error! "Unity version '#{version}' not found" unless unity
runner.run(unity, run_args, raw_logs: options[:raw_logs])
end
def credentials_actions
@@ -288,16 +297,17 @@
temp.insert(0, 'Unity') if temp.delete('Unity')
temp
end
def check_unity_presence(version: nil)
+ # idea: we could support matching 5.3.6p3 if passed 5.3.6
installed = Installer.create.installed
unity = installed.find { |u| u.version == version }
if unity.nil?
UI.verbose "Version #{version} of Unity is not installed yet"
else
- UI.verbose "Unity #{version} is installed at #{unity.path}"
+ UI.verbose "Unity #{version} is installed at #{unity.root_path}"
return unity
end
nil
end
@@ -310,11 +320,11 @@
if packages.include?('Unity')
UI.important 'Ignoring Unity module, it is already installed'
packages.delete('Unity')
# FIXME: Move me to the WindowsInstaller
- options[:installation_path] ||= unity.path if definition.os == :win
+ options[:installation_path] ||= unity.root_path if definition.os == :win
end
if unity.packages
unity.packages.each do |pack|
UI.important "Ignoring #{pack} module, it is already installed" if packages.delete(pack)
end
@@ -325,9 +335,15 @@
UI.error 'Please install Unity before any of its packages'
return false
end
end
true
+ end
+
+ def get_administrative_privileges(options)
+ U3dCore::Globals.use_keychain = true if options[:keychain] && Helper.mac?
+ UI.important 'Root privileges are required'
+ raise 'Could not get administrative privileges' unless U3dCore::CommandExecutor.has_admin_privileges?
end
end
end
# rubocop:enable ClassLength
end