Class: Spade::Packager::CLI::Base
- Inherits:
-
Thor
- Object
- Thor
- Spade::Packager::CLI::Base
- Defined in:
- lib/spade/packager/cli/base.rb
Instance Method Summary collapse
- #build ⇒ Object
- #install(*packages) ⇒ Object
- #installed(*packages) ⇒ Object
- #list(*packages) ⇒ Object
- #login ⇒ Object
- #new(name) ⇒ Object
- #push(package) ⇒ Object
- #uninstall(*packages) ⇒ Object
- #unpack(*paths) ⇒ Object
- #yank(package) ⇒ Object
Instance Method Details
#build ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/spade/packager/cli/base.rb', line 136 def build local = Spade::Packager::Local.new if local.logged_in? package = local.pack("package.json") if package.errors.empty? puts "Successfully built package: #{package.to_ext}" else = "Spade encountered the following problems building your package:" package.errors.each do |error| << "\n* #{error}" end abort end else abort LOGIN_MESSAGE end end |
#install(*packages) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/spade/packager/cli/base.rb', line 21 def install(*packages) report_arity_error("install") and return if packages.size.zero? begin packages.each do |package| installed = Spade::Packager::Remote.new.install(package, [:version], [:prerelease]) installed.each do |spec| say "Successfully installed #{spec.full_name}" end end rescue LibGems::InstallError => e abort "Install error: #{e}" rescue LibGems::GemNotFoundException => e abort "Can't find package #{e.name} #{e.version} available for install" rescue Errno::EACCES, LibGems::FilePermissionError => e abort e. end end |
#installed(*packages) ⇒ Object
41 42 43 44 45 |
# File 'lib/spade/packager/cli/base.rb', line 41 def installed(*packages) local = Spade::Packager::Local.new index = local.installed(packages) print_specs(packages, index) end |
#list(*packages) ⇒ Object
123 124 125 126 127 |
# File 'lib/spade/packager/cli/base.rb', line 123 def list(*packages) remote = Spade::Packager::Remote.new index = remote.list_packages(packages, [:all], [:prerelease]) print_specs(packages, index) end |
#login ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/spade/packager/cli/base.rb', line 62 def login highline = HighLine.new say "Enter your Spade credentials." begin email = highline.ask "\nEmail:" do |q| next unless STDIN.tty? q.readline = true end password = highline.ask "\nPassword:" do |q| next unless STDIN.tty? q.echo = "*" end rescue Interrupt => ex abort "Cancelled login." end say "\nLogging in as #{email}..." if Spade::Packager::Remote.new.login(email, password) say "Logged in!" else say "Incorrect email or password." login end end |
#new(name) ⇒ Object
130 131 132 133 |
# File 'lib/spade/packager/cli/base.rb', line 130 def new(name) ProjectGenerator.new(self, name, File.(name)).run end |
#push(package) ⇒ Object
91 92 93 94 95 96 97 98 |
# File 'lib/spade/packager/cli/base.rb', line 91 def push(package) remote = Spade::Packager::Remote.new if remote.logged_in? say remote.push(package) else say LOGIN_MESSAGE end end |
#uninstall(*packages) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/spade/packager/cli/base.rb', line 48 def uninstall(*packages) local = Spade::Packager::Local.new if packages.size > 0 packages.each do |package| if !local.uninstall(package) abort %{No packages installed named "#{package}"} end end else report_arity_error('uninstall') end end |
#unpack(*paths) ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/spade/packager/cli/base.rb', line 156 def unpack(*paths) local = Spade::Packager::Local.new paths.each do |path| begin package = local.unpack(path, [:target]) unpack_path = File.(File.join(Dir.pwd, [:target], package.to_full_name)) puts "Unpacked spade into: #{unpack_path}" rescue Errno::EACCES, LibGems::FilePermissionError => ex abort "There was a problem unpacking #{path}:\n#{ex.}" end end end |
#yank(package) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/spade/packager/cli/base.rb', line 103 def yank(package) if [:version] remote = Spade::Packager::Remote.new if remote.logged_in? if [:undo] say remote.unyank(package, [:version]) else say remote.yank(package, [:version]) end else say LOGIN_MESSAGE end else say "Version required" end end |