Node Boiler Plate setup

Was starting to work on a small Trello powerup utility and had to quickly start a Node + Express server.

My First thought was to use the 'npm init' command and go through the usual drill but then decided to look for a better way. A quick search online led to an interesting post by Phil Nash which runs you through the steps to build a bash script for the same.

Steps i followed to config my script

Customised my npm config list

There are a number of defaults you can set; author name, author email, author url, the license, and the version. To set them, you can edit the npm config file > npm config edit  or  edit them from the command line. The latter was a faster approach to i took it :

npm set init.author.name "Your name"
npm set init.author.email "your@email.com"
npm set init.author.url "https://your-url.com"
npm set init.license "MIT"
npm set init.version "1.0.0"

Once these configs are setup, npm init -y command will always add the right settings.

Build the INIT SCRIPT

Once the Config was in place, i just copied the function to create the node project to my bash profile. The Function Phil shared was quite decent so i used it as it.

function node-project {
  git init
  npx license $(npm get init.license) -o "$(npm get init.author.name)" > LICENSE
  npx gitignore node
  npx covgen "$(npm get init.author.email)"
  npm init -y
  git add -A
  git commit -m "Initial commit"
}

I just added the function to my  ~/.bash_profile. jumped into the empty project folder and ran the  source ~/.bash_profile command to access the function and then ran the node-project.

Thats it the project was created and i was ready to roll.