Like most web developers. I prefer to save time by automating low level, mundane tasks.
Laziness is a trait of a good developer.
When I started to use WordPress again, I WAS NOT excited about using the FTP protocol to ship off changes to my theme. I wanted a simple and easy use process to deploy updates to my theme and also automate a few processes that I needed to support as part of using Sass and Compass to create my CSS styles.
What’s the alternative? FTP? Nope. Typing the rsync command by hand each time? Nope again.
This is a simple Rakefile I wrote that helps me to do all this in simple and concise manner.
Features:
- Clear and generate tasks that clear and generate new styles (via Compass)
- Deploy task that clears the styles, generates new styles and finally deploys the theme using Rsync
ssh_user = "user@domain.com" # for rsync deployment
remote_root = "~/path/to/remote/" # for rsync deployment
namespace :styles do
desc "Clear styles"
task :clear do
puts "*** Clearing styles ***"
system "compass clean"
end
desc "Generate styles"
task :generate => [:clear] do
puts "*** Generating styles ***"
system "compass compile"
end
end
desc "Clears the styles, generates new ones and then deploys the theme"
task :deploy => 'styles:generate' do
puts "*** Deploying the site ***"
system("rsync -avz --delete . #{ssh_user}:#{remote_root}")
end
It’s 21 lines and simple to use. Besides, rake deploy is much better than what most WordPress users are doing to deploy updates to their theme. Capistrano could work too, but IMO would be over-kill. Rsync is a much better fit, and using the --delete option ensures that you delete files that don’t exist on the sending side. Keeps it simple and clean.
This Rakefile is a bit opinionated and assumes you’re using Sass and Compass.