class Zapnito::Cli::Commands::Environment

Public Instance Methods

preview() click to toggle source
# File lib/zapnito/cli/commands/environment.rb, line 36
def preview
  theme = Services.local.load
  link = zapnito.preview_link(theme)
  puts "link: #{link}"
  Launchy.open(link)
end
publish() click to toggle source
# File lib/zapnito/cli/commands/environment.rb, line 11
def publish
  theme = Services.local.load
  puts "---> Publishing #{theme.tenant_slug}"

  release_config = zapnito.s3_upload_urls_for_theme(theme)
  Services.s3.upload_theme(theme, release_config)
  zapnito.build_release(theme)

  puts "---> Published #{theme.tenant_slug}/#{theme.revision}"
rescue Exception => e
  if e.try(:response).try(:code) == 406
    show_sass_error(e)
  else
    raise e
  end
end

Private Instance Methods

api_token() click to toggle source
# File lib/zapnito/cli/commands/environment.rb, line 56
def api_token
  configatron.environments[environment].api_token!
end
basepath() click to toggle source
# File lib/zapnito/cli/commands/environment.rb, line 60
def basepath
  configatron.environments[environment].basepath!
end
environment() click to toggle source
# File lib/zapnito/cli/commands/environment.rb, line 64
def environment
  raise "not implemented"
end
show_sass_error(e) click to toggle source
# File lib/zapnito/cli/commands/environment.rb, line 49
def show_sass_error(e)
  error = JSON.parse(e.response)["error"]
  puts "---! #{error["message"]}"
  puts "=========================="
  puts "---! #{error["sass_backtrace"]}"
end
zapnito() click to toggle source
# File lib/zapnito/cli/commands/environment.rb, line 45
def zapnito
  Services.zapnito(api_token, basepath)
end