Add rake provision system

This commit is contained in:
Henrik Lissner 2014-04-11 03:31:44 -04:00
parent 925d13a8db
commit 00ffb41218
19 changed files with 321 additions and 1 deletions

View file

@ -1,4 +1,5 @@
source 'https://rubygems.org' source 'https://rubygems.org'
gem 'prowl'
gem 'simple-rss' gem 'simple-rss'
gem 'ruby-growl' gem 'ruby-growl'
gem 'rake'
gem 'colorize'

0
rake/README.md Normal file
View file

0
rake/gamedev.rake Normal file
View file

57
rake/homebrew.rake Normal file
View file

@ -0,0 +1,57 @@
require_relative "lib/output"
require_relative "lib/homebrew"
desc "Ensure homebrew is installed and up to date"
task :homebrew => 'homebrew:update'
namespace :homebrew do
task :install do
unless Homebrew.is_installed?
echo "Installing Homebrew..."
Homebrew.bootstrap
end
Homebrew.tap('homebrew/dupes')
# Homebrew.tap('homebrew/python')
Homebrew.tap('phinze/cask')
%w{
apple_gcc42
coreutils
wget
curl
tree
git
cask
the_silver_searcher
tmux
gist
}.each { |pkg| Homebrew.install pkg }
%w{
dropbox
firefox
appcleaner
vagrant
virtualbox
growlnotify
iterm2
launchbar
java
}.each { |app| Homebrew.install_cask app }
end
task :update => :install do
echo "Updating homebrew..."
Homebrew.update
end
desc "Remove homebrew cleanly"
task :remove do
Homebrew.destroy if Homebrew.is_installed?
end
end

15
rake/init.rake Normal file
View file

@ -0,0 +1,15 @@
require_relative 'lib/output'
desc "Provision the node"
task :init,:node do |t,args|
args.with_defaults(:node => `hostname`.strip)
# TODO: chop of the *.local in osx hostnames
path = "#{File.dirname(__FILE__)}/node/#{args.node}.rb"
if File.exists?(path)
echo "Setting up node: #{args.node}"
require_relative "node/#{args.node}"
else
echo "#{args.node} node does not exist!"
end
end

2
rake/lib/fileutils.rb Normal file
View file

@ -0,0 +1,2 @@

9
rake/lib/git.rb Normal file
View file

@ -0,0 +1,9 @@
include Rake::DSL
def git(url,dest)
sh "git clone #{url} #{dest}" unless File.exists?(dest)
end
def github(repo,dest)
git "git@github.com:#{repo}.git", dest
end

63
rake/lib/homebrew.rb Normal file
View file

@ -0,0 +1,63 @@
include Rake::DSL
module Homebrew
BIN = "/usr/local/bin/brew"
def self.bootstrap
unless self.is_installed?
sh 'ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"'
sh 'exec $SHELL -l'
end
end
def self.destroy
if self.is_installed?
sh 'rm -rf /usr/local/Cellar /usr/local/.git ~/Library/Caches/Homebrew'
sh 'brew prune'
['Library/Homebrew', 'Library/Aliases', 'Library/Formula', 'Library/Contributions'].each do |dir|
sh "rm -r #{dir}"
end
end
end
def self.install(keg, options=nil)
sh "#{BIN} install #{keg} #{options}" unless self.is_keg_installed?(keg)
end
def self.install_cask(cask, options=nil)
sh "#{BIN} cask install #{cask} #{options}" unless self.is_cask_installed?(cask)
end
def self.tap(tap)
sh "#{BIN} tap #{tap}" unless self.is_tapped? tap
end
def self.remove(keg)
sh "#{BIN} remove #{keg}"
end
def self.has_keg?(keg)
system("#{BIN} search #{keg}")
end
def self.is_keg_installed?(keg)
system("#{BIN} list | grep -w '#{keg}'")
end
def self.is_cask_installed?(cask)
system("#{BIN} cask list | grep -w '#{cask}'")
end
def self.is_tapped?(tap)
system("#{BIN} tap | grep -w '#{tap}'")
end
def self.is_installed?
File.exists?("usr/local/bin/brew")
end
def self.update()
sh "#{BIN} update && #{BIN} upgrade"
end
end

5
rake/lib/output.rb Normal file
View file

@ -0,0 +1,5 @@
require 'colorize'
def echo(msg)
puts "=> #{msg}".bold.green
end

8
rake/node/callisto.rb Normal file
View file

@ -0,0 +1,8 @@
%w{
osx
homebrew
zsh
vim
rbenv
mongodb
}.each { |task| Rake::Task[task].invoke }

1
rake/node/ganymede.rb Normal file
View file

@ -0,0 +1 @@
require_relative "io"

29
rake/node/io.rb Normal file
View file

@ -0,0 +1,29 @@
require_relative 'lib/homebrew'
%w{
osx
homebrew
zsh
vim
gamedev:sfml
gamedev:love2D
gamedev:unity
rbenv
pyenv
}.each { |task| Rake::Task[task].invoke }
%w{
evernote
transmit
transmission
vlc
flux
skype
adium
codekit
mongohub
sequel-pro
scrivener
omnigraffle
mindnode-pro
}.each { |app| Homebrew.install_cask app }

0
rake/node/test.rb Normal file
View file

0
rake/node/titan.rb Normal file
View file

47
rake/osx.rake Normal file
View file

@ -0,0 +1,47 @@
require_relative 'lib/output'
task :osx do
echo "Applying OSX settings"
sh 'chflags nohidden "${HOME}/Library"'
sh 'defaults write NSGlobalDomain KeyRepeat -int 0'
# Disable press-and-hold for keys in favor of key repeat
sh 'defaults write ApplePressAndHoldEnabled -bool false'
sh 'defaults write NSGlobalDomain AppleKeyboardUIMode -int 3'
sh 'defaults write NSGlobalDomain AppleFontSmoothing -int 2'
sh 'defaults write com.apple.dock autohide -bool true'
sh 'defaults write NSGlobalDomain AppleShowAllExtensions -bool true'
sh 'defaults write com.apple.finder ShowStatusBar -bool true'
sh 'defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true'
# Disable app quarantine
sh 'defaults write com.apple.LaunchServices LSQuarantine -bool false'
# Disable auto-correct
sh 'defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false'
sh 'defaults write com.apple.finder _FXShowPosixPathInTitle -bool true'
# Avoid creating .DS_Store files on network volumes
sh 'defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true'
# Disable the warning when changing a file extension
sh 'defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false'
sh 'defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true'
# Disable local Time Machine backups
# sh 'hash tmutil &> /dev/null && sudo tmutil disablelocal'
# Finder: allow text selection in Quick Look
sh 'defaults write com.apple.finder QLEnableTextSelection -bool true'
# When performing a search, search the current folder by default
sh 'defaults write com.apple.finder FXDefaultSearchScope -string "SCcf"'
# Use column view
sh 'defaults write com.apple.finder FXPreferredViewStyle -string "clmv"'
sh 'killall Finder'
sh 'killall Dock'
end

0
rake/pyenv.rake Normal file
View file

27
rake/rbenv.rake Normal file
View file

@ -0,0 +1,27 @@
require_relative 'lib/homebrew'
task :rbenv do
end
namespace :rbenv do
BREWS = %w{rbenv ruby-build rbenv-bundler rbenv-vars rbenv-gem-rehash}
task :install do
BREWS.each { |pkg| Homebrew.install pkg }
end
if Dir.exists?(File.expand_path("~/.rbenv"))
task :remove do
BREWS.each { |pkg| Homebrew.remove pkg }
sh "rm -rf ~/.rbenv"
end
task :update => :install do
end
end
end

28
rake/vim.rake Normal file
View file

@ -0,0 +1,28 @@
require_relative "lib/output"
require_relative "lib/homebrew"
desc "Ensure vim/macvim is installed and up to date"
task :vim => 'vim:update'
namespace :vim do
task :install => 'homebrew' do
%w{lua luajit}.each { |pkg| Homebrew.install pkg }
%w{vim macvim}.each { |pkg| Homebrew.install(pkg, '--with-lua --with-luajit') }
github 'hlissner/vim', '~/.vim'
end
task :update => :install do
echo "Updating homebrew..."
Homebrew.update
end
desc "Remove homebrew cleanly"
task :remove do
echo "Uninstalling Homebrew"
Homebrew.destroy
end
end

28
rake/zsh.rake Normal file
View file

@ -0,0 +1,28 @@
require_relative 'lib/git'
desc "Ensure zsh and oh-my-zsh is installed and set"
task :zsh => 'zsh:update'
namespace :zsh do
task :install do
unless Dir.exists?(File.expand_path("~/.oh-my-zsh"))
echo "Installing oh-my-zsh"
github 'robbyrussell/oh-my-zsh', '~/.oh-my-zsh'
sh '~/.oh-my-zsh/install.sh'
end
unless `printenv SHELL | grep "/bin/zsh"`
echo "Setting shell to zsh"
sh "chsh -s /bin/zsh"
sh "exec /bin/zsh -l"
end
end
task :update => :install do
echo "Updating oh-my-zsh"
sh 'cd ~/.oh-my-zsh && git pull'
end
end