NodeJS Package Manager
If you use node you may have heard of the Kiwi Package Manager, if not its simply a package management system for node modules. Although development of kiwi is still early, its already 100% usable and available to the community.
Installing Packages (seeds)
Kiwi’s packages aka seeds, are simply tarballs abstracted using the extension ".seed". Installing the latest version of a specific seed using kiwi is insanely simple:
$ kiwi install haml
This command will resolve the latest version, and install it (and it’s dependencies) for you. Now to install a specific version we can simply pass the version number:
$ kiwi install haml 0.3.0
Kiwi also supports the following operators which can be used in both install-time resolution, as well as the runtime require() method provided by kiwi.
n/a Equal to = Equal to > Greater than >= Greater than or equal to >~ Greater than or equal to with compatibility (major must match)
So for example, the following command will install any version over 0.2.0, at which point the server will resolve the match.
$ kiwi install haml '> 0.2.0'
The seeds currently installed can easily be displayed using the list command:
$ kiwi list express : 0.9.0 markdown : 0.0.1 sass : 0.4.0
Now lets say we hate that version of haml we just downloaded, we can remove the specific version:
$ kiwi uninstall haml 0.3.0
or using the rm alias:
$ kiwi rm haml 0.3.0
Searching For Packages
Searching the kiwi server for seeds is also very easy. With built-in pattern matching you can search for packages from the command-line with ease:
Or you can list everything available:
$ kiwi search ...
Since kiwi’s server has version resolution built in, auto-updating can be done with the update command:
$ kiwi update
Requiring Seeds During Runtime
With kiwi installed you can require(‘kiwi’) and use kiwi’s require() method, which is the same as node’s however accepts an optional version string which is resolved in the same manor mentioned above. However you will want to read the Library Developer Best Practices article in the kiwi wiki.
$ kiwi install haml $ node-repl node> require('kiwi').require('haml', '> 0.2.0').render('!!! xml') '<?xml version="1.0" encoding="utf-8" ?>'
Kiwi REPL (Interactive Console)
When kiwi is executed with no arguments a REPL will be created, allowing you to utilize kiwi commands in it’s own shell.
$ kiwi kiwi> list express : 0.9.0 haml : 0.3.0 markdown : 0.0.1 sass : 0.4.0 kiwi> rm sass uninstall : all versions of sass kiwi> list express : 0.9.0 haml : 0.3.0 markdown : 0.0.1 kiwi> install sass install : sass version : 0.4.0 create : /Users/tjholowaychuk/.kiwi/current/seeds/sass/0.4.0 fetch : 0.4.0.seed unpack : /Users/tjholowaychuk/.kiwi/current/seeds/sass/0.4.0/sass.seed remove : /Users/tjholowaychuk/.kiwi/current/seeds/sass/0.4.0/sass.seed check : dependencies kiwi> list express : 0.9.0 haml : 0.3.0 markdown : 0.0.1 sass : 0.4.0
More Kiwi !
Kiwi has many more features, so until next time:
$ kiwi help
$ kiwi help name-of-command