Introduction
Whenever I start coding a new project, I tend to forget about adding a sophisticated, fully automated build pipeline. It's even worse with Nodejs/TypeScript, where everything seems to work out just fine in Visual Studio... but forcing everybody to use VS somewhat decreases willingness for participation, so at some point in time, we have to add some automation.
Grunt is great for things like this. But not for lazy people like me. There's too much ceremony, and the gruntfile tends to get a mess in minutes. Also, when using Grunt with 3rd Party libraries that don't have targets (phpunit anyone?) you really have to get dirty to execute one task multiple times.
The solution for this (as for very big files where the grunt file has become too big to open because your computer does not has enough RAM) is itbldz - a simple wrapper for grunt.
It has no gruntfile, the grunt modules are in (and loaded from) one single location and it comes with more awesome blabla... you can read more about it in the marketing brochure.
Getting Started
Open the root of your project in your terminal/powershell, and type:
npm install itbldz -g
init-itbldz
Follow the assistant, and set build to TypeScript and deployment to npm. Then type:
build-it
Done.
Congratulations, you now have a build :blush:
Deploy Your Code to npm
Now that your project has an automated build, you may want to share it with the world when then tests are green. We will now compile it, run the tests and then publish it to npm. If you haven't created a user on npm, do this now. Then type:
ship-it
Done.
Congratulations, you now have a deployment :blush:
Travis CI Your Code
Sometimes, you may be even too lazy to type so much. You'd rather have it on git and let Travis CI take care of the rest. Type:
init-itbldz
Again, select deploy only (this will leave your build untouched) and choose npm (but select only to bump the version) and gitHub. Open the deploy.json and add your github credentials to "publish.git" as described here: https://github.com/geddski/grunt-release.
Setup Travis CI by adding the following .travis.yml file to your project:
language: node_js
node_js:
- "0.10"
- "iojs"
before_install: npm install -g itbldz
deploy:
provider: npm
email: "YOUR EMAIL ADDRESS"
api_key: "YOUR API KEY"
skip_cleanup: true
See Travis Docs to learn how to get the API key. Configure your travis to work with your github, and type:
ship-it
Done! Want to trigger a new travis build and deploy again? Type:
ship-it
Done!
Only want to build, and not deploy to Ser Travis?
build-it
Congratulations, you now have continuous deployment! :blush:
Wanna Do the Same in Another Language?
Do...
init-itbldz
...and either select your language or the one that matches your language-scenario best and edit the created *.json to use the grunt-tasks for your language.
Done!
Wanna Dockerize It?
You totally may want a docker build-slave for that, now won't you? Create the following Dockerfile:
FROM centos:centos6
# Enable EPEL for Node.js
RUN curl -sL https://rpm.nodesource.com/setup | bash -
# Install Node.js and npm
RUN yum install -y npm
# Install itbldz
RUN npm install -g itbldz
# continue with your stuff...
Summary
For me, this is easy enough. Hope it is for you too!
Did you know?
- itbldz is a wrapper for grunt so you can use all existing grunt tasks
- itbldz is an Open Source Project