Class: VpsCli::Install

Inherits:
Object
  • Object
show all
Defined in:
lib/vps_cli/install.rb

Overview

Installes the required packages

Class Method Summary collapse

Class Method Details

.add_language_serversObject

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



195
196
197
198
199
200
201
202
203
204
205
206
207
# 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_installObject

Runs through multiple methods listed below

See Also:

  • #prep
  • #packages


23
24
25
26
27
# File 'lib/vps_cli/install.rb', line 23

def self.all_install
  prep
  packages
  install_non_apt_packages
end

.dockerObject

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



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# 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

.eslintObject

def self.powerlevel10k

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

end



213
214
215
# File 'lib/vps_cli/install.rb', line 213

def self.eslint
  Rake.sh('npm install -g eslint')
end

.fullObject

Run the #all_install method, simply a wrapper to catch errors

and check if the user is running linux

See Also:



11
12
13
14
15
16
17
18
# 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_autosuggestionsObject



150
151
152
153
154
155
# 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_gemsObject

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



183
184
185
186
187
# 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_packagesObject

runs #all_install without the sudo apt-get packages

See Also:

  • #other_tools
  • #neovim_support
  • #omz_full_install
  • Setup.full
  • #install_tmux_plugin_manager_and_plugins
  • #plug_install_vim_neovim
  • #install_gems
  • #add_language_servers
  • #node_js


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# 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_zshObject

Install Oh my zsh



143
144
145
146
147
148
# 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_highlightingObject

Install Oh my zsh syntax highlighting



159
160
161
162
163
164
# 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_pluginsObject

will install tmux plugin manager



173
174
175
176
177
178
179
# 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_supportObject

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



123
124
125
126
127
128
129
# 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_installObject

Runs the following commands, simply a wrapper

See Also:

  • #install_oh_my_zsh
  • #install_syntax_highlighting
  • #install_autosuggestions


135
136
137
138
139
# File 'lib/vps_cli/install.rb', line 135

def self.omz_full_install
  install_oh_my_zsh
  install_syntax_highlighting
  install_autosuggestions
end

.other_toolsObject

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



78
79
80
81
82
83
84
85
86
87
88
89
# 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

.packagesObject

Runs through items found in Packages::UBUNTU

See Also:



64
65
66
67
68
69
70
71
72
73
74
# 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_neovimObject

Runs PlugInstall for neovim



167
168
169
170
# 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

.prepObject

simply runs apt update, upgrade, and dist-upgrade



56
57
58
59
60
# 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