Class: Wooget::Paket
- Inherits:
-
Object
- Object
- Wooget::Paket
- Defined in:
- lib/wooget/paket.rb
Constant Summary collapse
- @@paket_path =
File.(File.join(__FILE__, "..", "third_party", "paket.exe"))
- @@unity3d_path =
File.(File.join(__FILE__, "..", "third_party", "paket.unity3d.exe"))
Class Method Summary collapse
- .env_vars ⇒ Object
- .execute(args) ⇒ Object
- .install(options = {}) ⇒ Object
- .installed?(project_path, package) ⇒ Boolean
- .pack(options) ⇒ Object
- .push(auth, url, package) ⇒ Object
- .should_generate_unity3d_references?(path = Dir.pwd) ⇒ Boolean
- .unity3d_execute(args) ⇒ Object
- .update(package = nil, options = {}) ⇒ Object
Class Method Details
.env_vars ⇒ Object
50 51 52 |
# File 'lib/wooget/paket.rb', line 50 def self.env_vars "USERNAME=#{Wooget.credentials[:username]} PASSWORD=#{Wooget.credentials[:password]}" end |
.execute(args) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/wooget/paket.rb', line 6 def self.execute args cmd = "mono #{ @@paket_path} #{args}" Wooget.log.debug "Running #{cmd}" exec cmd end |
.install(options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/wooget/paket.rb', line 20 def self.install ={} [:path] ||= Dir.pwd commands = ["#{env_vars} mono #{@@paket_path} install #{"--force" if [:force]}"] commands << "#{env_vars} mono #{@@unity3d_path} install" if Util.is_a_unity_project_dir([:path]) commands.each do |cmd| reason, exitstatus = Util.run_cmd(cmd, [:path]) { |log| Wooget.no_status_log log } unless exitstatus == 0 Wooget.log.error "Install failed:\n #{reason}" break end end end |
.installed?(project_path, package) ⇒ Boolean
54 55 56 57 58 59 60 61 |
# File 'lib/wooget/paket.rb', line 54 def self.installed? project_path, package abort "Not a valid paket dir - #{project_path}" unless Util.is_a_unity_project_dir(project_path) or Util.is_a_wooget_package_dir(project_path) lock_file = File.join(project_path, "paket.lock") return false unless File.exists? lock_file File.open(lock_file).read.lines.any? { |l| l =~ /\s*#{package}\s+/ } end |
.pack(options) ⇒ Object
70 71 72 73 |
# File 'lib/wooget/paket.rb', line 70 def self.pack pack_cmd = "#{env_vars} mono #{@@paket_path} pack output #{[:output]} version #{[:version]} releaseNotes \"#{[:release_notes]}\"" Util.run_cmd(pack_cmd, [:path] || Dir.pwd) { |log| Wooget.no_status_log log } end |
.push(auth, url, package) ⇒ Object
75 76 77 78 |
# File 'lib/wooget/paket.rb', line 75 def self.push auth, url, package push_cmd = "#{env_vars} nugetkey=#{auth} mono #{@@paket_path} push url #{url} file #{package}" Util.run_cmd(push_cmd) { |log| Wooget.no_status_log log } end |
.should_generate_unity3d_references?(path = Dir.pwd) ⇒ Boolean
63 64 65 66 67 68 |
# File 'lib/wooget/paket.rb', line 63 def self.should_generate_unity3d_references? path=Dir.pwd #if the references file doesnt exist, or it does exist and # it contains the automanage tag then we can rewrite it auto_manage_tag = "[!automanage!]" !File.exists?(File.join(path, "paket.unity3d.references")) or (Util.file_contains? File.join(path, "paket.dependencies"), auto_manage_tag) end |
.unity3d_execute(args) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/wooget/paket.rb', line 13 def self.unity3d_execute args cmd = "mono #{@@unity3d_path} #{args}" Wooget.log.debug "Running #{cmd}" exec cmd end |
.update(package = nil, options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/wooget/paket.rb', line 35 def self.update package=nil, ={} [:path] ||= Dir.pwd commands = ["#{env_vars} mono #{@@paket_path} update #{"nuget #{package}" if package} #{"--force" if [:force]}"] commands << "#{env_vars} mono #{@@unity3d_path} install" if Util.is_a_unity_project_dir([:path]) commands.each do |cmd| reason, exitstatus = Util.run_cmd(cmd, [:path]) { |log| Wooget.no_status_log log } unless exitstatus == 0 Wooget.log.error "Update failed:\n #{reason}" break end end end |