Sunday, July 7, 2013

Creating a private kanso package repository

Setting up a private kanso repository is an easy task and it makes a lot of sense. I consider using kanso and CouchDB for a rather large project which should be split up into many smaller packages. That way I can make use of kansos package mechanism and don't have to repeat myself when it comes to code shared by all the different apps.

Of course I could easily use the public package repository and whenever an app is generic enough it should actually be used. But when your package is highly specialised or not meant to be published having a private repository gets you around that problem.

The first thing you need to do is setting up the repository itself. Check out the Github Project and install it to a CouchDB server of your choice using kanso. And that's really all there's to it. It's amazing how simple it is.

Now use the --repository or --repo (that's not consistent yet) parameter to specify your local repository. Here's an example:

kanso publish --repo http://localhost:5984/kansorep/

In your final step you need to edit `lib/kansorc` within your kanso installation. Find the line that says `export.DEFAULTS` and add your repository URL. Here's an example:

exports.DEFAULTS = {
    repositories: [
      "http://kan.so/repository",
      "http://localhost:5984/kansorep"
    ],
    env: {
        // custom push locations
    }
};

Once that's done, kanso is smart enought to look for packages within all both repositories. That means that you'll be able to use `kanso install` without having to worry where the packages you're looking for are located.

I've gotta admit, that the repository handling of kanso isn't great yet. There's an old discussion touching that subject. Yet it doesn't look like that the functions suggested in there have been implemented yet.

No comments :

Post a Comment