Jumpstarting development projects with grunt

Some time ago I came across this WordPress plugin grunt-init template by 10up and began fiddling with it to make it stick to my coding habits and to be able to quickly deploy and work on plugins and themes remotely and from any platform. A similar solution exists for themes again by 10up.
“Remotely” to me means “from a CLI” and while I love CodeKit using grunt is just easier when using a command line and, being based on Node.js, cross-platform the way I like it.

Installing Node.js and grunt

I begin by installing Node.js using either Mac or Windows installers. The installer prompts me to check my path to be sure that the folder Node.js has been installed in has been added to the system path. In a Unix machine I use

echo $PATH

and check that /usr/local/bin is in it. In a Windows machine I enter

echo %path%

at the Command Prompt and check that C:\path-to-node\nodejs is among the listed folders; on both OSes installers should take care of it though. To test that Node.js has been installed properly I run the same command on Unix and Windows machines

node -v

to get Node.js installed version.

Install grunt CLI and grunt-init

To install grunt, as detailed by official site instructions run


npm install -g grunt-cli
npm install -g grunt-init

in Terminal or Command prompt. Administrator rights might be needed to complete installation so either run Command prompt with administrator rights on Windows or use sudo on Unix.

Move grunt-init templates folder in Dropbox

When invoked grunt-init will use a specified template to create a project scaffold. Those templates I want to keep in sync between different machines and hence have to point both Windows and Mac versions of grunt-init to my Dropbox templates folder using symbolic links (“junctions” in Windows).
In Windows I enter

mklink c:\users\your-username.grunt-init c:\users\your-username\dropbox\path-to-grunt-init-templates-folder

I keep my templates in a folder called grunt-init_templates in Dropbox. Then on my Mac I enter

ln -s ~/Dropbox/path-to-grunt-init-templates-folder ~/.grunt-init

Get some templates and enjoy

To get started using grunt-init simply copy, download or clone some project templates into the templates folder and begin scaffolding as detailed in grunt-init documentation. You can, of course, make your own and my rule of thumb here is to make a template for any project I have to scaffold more than 3 times.

I appreciate your input