class VpsCli::Install

Installes the required packages

Public Class Methods

add_language_servers() click to toggle source

Adds the following language servers bash-language-server vscode-html-languageserver-bin vscode-css-languageserver-bin javascript-typescript-langserver does not add solargraph for ruby, installed via gems

# File lib/vps_cli/install.rb, line 195
def self.add_language_servers
  npm_install = 'npm install --global'
  # bash
  Rake.sh("#{npm_install} bash-language-server --unsafe-perm")
  # html
  Rake.sh("#{npm_install} vscode-html-languageserver-bin")
  # css
  Rake.sh("#{npm_install} vscode-css-languageserver-bin")
  # js
  Rake.sh("#{npm_install} javascript-typescript-langserver")
  # Dockerfile
  Rake.sh("#{npm_install} dockerfile-language-server-nodejs")
end
all_install() click to toggle source

Runs through multiple methods listed below @see prep @see packages

# File lib/vps_cli/install.rb, line 23
def self.all_install
  prep
  packages
  install_non_apt_packages
end
docker() click to toggle source

installs docker-machine as well as adding docker to sudo group

# File lib/vps_cli/install.rb, line 92
  def self.docker
    # add docker
    username = Dir.home.split('/')[2]
    begin
      Rake.sh('sudo groupadd docker')
      Rake.sh("sudo usermod -aG docker #{username}")
    rescue RuntimeError
      puts 'docker group already exists.'
      puts 'moving on...'
    end

    docker_machine = "base=https://github.com/docker/machine/releases/download/v0.16.0 && \
curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/tmp/docker-machine && \
sudo install /tmp/docker-machine /usr/local/bin/docker-machine"
    begin
      Rake.sh(docker_machine)
    rescue StandardError => e
      VpsCli.errors << e.exception('Unable to install docker-machine')
    end
  end
eslint() click to toggle source

def self.powerlevel10k

Rake.sh('git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k')

end

# File lib/vps_cli/install.rb, line 213
def self.eslint
  Rake.sh('npm install -g eslint')
end
full() click to toggle source

Run the all_install method, simply a wrapper to catch errors

and check if the user is running linux

@see all_install

# File lib/vps_cli/install.rb, line 11
def self.full
  unless OS.linux?
    puts 'You are not running on linux. No packages installed.'
    return
  end

  all_install
end
install_autosuggestions() click to toggle source
# File lib/vps_cli/install.rb, line 150
def self.install_autosuggestions
  auto = File.join(OMZ_PLUGINS, 'zsh-autosuggestions')
  return if File.exist?(auto)

  Rake.sh("git clone https://github.com/zsh-users/zsh-autosuggestions #{auto}")
end
install_gems() click to toggle source

Installs all gems located in Packages::GEMS Also will runs 'yard gems' to document all gems via yard

# File lib/vps_cli/install.rb, line 183
def self.install_gems
  Packages::GEMS.each { |g| Rake.sh("gem install #{g}") }
  # documents all gems via yard
  Rake.sh('yard gems')
end
install_non_apt_packages() click to toggle source

runs all_install without the sudo apt-get packages @see other_tools @see neovim_support @see omz_full_install @see Setup#full @see install_tmux_plugin_manager_and_plugins @see plug_install_vim_neovim @see install_gems @see add_language_servers @see node_js

# File lib/vps_cli/install.rb, line 39
def self.install_non_apt_packages
  # nvm
  # phpenv
  other_tools
  neovim_support
  omz_full_install
  Setup.full
  install_tmux_plugin_manager_and_plugins
  plug_install_vim_neovim
  install_gems
  # node_js
  add_language_servers
  # powerlevel10k
  eslint
end
install_oh_my_zsh() click to toggle source

Install Oh my zsh @see github.com/zsh-users/zsh-autosuggestions

# File lib/vps_cli/install.rb, line 143
def self.install_oh_my_zsh
  return if Dir.exist?(OMZ_DIR)

  Rake.sh('git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh')
  Rake.sh(%(sudo usermod --shell /bin/zsh "$USER"))
end
install_syntax_highlighting() click to toggle source

Install Oh my zsh syntax highlighting @see github.com/zsh-users/zsh-syntax-highlighting.git

# File lib/vps_cli/install.rb, line 159
def self.install_syntax_highlighting
  syntax = File.join(OMZ_PLUGINS, 'zsh-syntax-highlighting')
  return if File.exist?(syntax)

  Rake.sh("git clone https://github.com/zsh-users/zsh-syntax-highlighting.git #{syntax}")
end
install_tmux_plugin_manager_and_plugins() click to toggle source

will install tmux plugin manager

# File lib/vps_cli/install.rb, line 173
def self.install_tmux_plugin_manager_and_plugins
  install_path = File.join(Dir.home, '.tmux', 'plugins', 'tpm')
  return if File.exist?(install_path)

  Rake.mkdir_p(install_path)
  Rake.sh("git clone https://github.com/tmux-plugins/tpm #{install_path}")
end
neovim_support() click to toggle source

adds neovim support via pip3 Also adds neovim via npm for js support

# File lib/vps_cli/install.rb, line 123
def self.neovim_support
  Rake.sh('sudo -H pip2 install neovim --system')
  Rake.sh('sudo -H pip3 install neovim --system')
  Rake.sh('pip3 install --user pynvim')
  Rake.sh('pip3 install --user --upgrade pynvim')
  Rake.sh(%(yes "\n" | sudo npm install -g neovim))
end
omz_full_install() click to toggle source

Runs the following commands, simply a wrapper @see install_oh_my_zsh @see install_syntax_highlighting @see install_autosuggestions

# File lib/vps_cli/install.rb, line 135
def self.omz_full_install
  install_oh_my_zsh
  install_syntax_highlighting
  install_autosuggestions
end
other_tools() click to toggle source

installs various other tools and fixes an issue with npm / nodejs installs heroku, ngrok, and adds docker groups

# File lib/vps_cli/install.rb, line 78
def self.other_tools
  # add heroku
  Rake.sh('sudo snap install heroku --classic')
  # add tmux plugin manager
  tmp_plugins = File.join(Dir.home, '.tmux', 'plugins', 'tpm')
  unless Dir.exist?(tmp_plugins)
    Rake.mkdir_p(tmp_plugins)
    Rake.sh('git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm')
  end
  # add ngrok
  Rake.sh('sudo npm install --unsafe-perm -g ngrok')
end
packages() click to toggle source

Runs through items found in Packages::UBUNTU @see Packages::UBUNTU

# File lib/vps_cli/install.rb, line 64
def self.packages
  pkgs = Packages::UBUNTU.flatten.join(' ').to_s
  Rake.sh("sudo apt-get install -y #{pkgs}")

  begin
  rescue StandardError => e
    VpsCli.errors << e
  end

  puts 'Completed apt-get install on all packages.'
end
plug_install_vim_neovim() click to toggle source

Runs PlugInstall for neovim

# File lib/vps_cli/install.rb, line 167
def self.plug_install_vim_neovim
  Rake.sh(%(nvim +'PlugInstall --sync' +qa))
  Rake.sh(%(nvim +'PlugUpdate --sync' +qa))
end
prep() click to toggle source

simply runs apt update, upgrade, and dist-upgrade

# File lib/vps_cli/install.rb, line 56
def self.prep
  Rake.sh('sudo apt-get update')
  Rake.sh('sudo apt-get upgrade -y')
  Rake.sh('sudo apt-get dist-upgrade -y')
end