Hello codeplex!

Now that I've done the (admittedly easy) work of getting ghost setup, I can dive into learning node. This will essentially be hello, world!, but that isn't particularly interesting to anybody (and it is trivial to find yourself), so I am going to challenge myself a little bit. I've recently been evaluating with continuous deployment at work, and coincidentally for some personal projects. One that I am particularly intrigued by is strider. Since it is written in node, it seems promising as a platform for my experiments. My goal is to actually create a useful plugin, so hopefully I can manage to cobble something together!

Now, I have a couple of projects hosted on codeplex, so any continuous deployment solution for me needs to support it as a source control provider. Seeing as strider has support for plugins, my first forray will be creating just such a plugin. I searched the internet for quite a while to try and find a basic node tutorial without much success. Besides how to node, I found a fairly inexpensive e-book that wound up helping a lot.

Okay, for my first trick test, I am just going to try to get the list of repos that I have on codeplex. According to the api docs, this is farily simple. Honestly the biggest snag I ran into was that I was trying to use the http node module to call the api. The docs are clear that you need to use https, but I foolishly did not realize that was a separate module in node. With that much need knowledge, it was pretty darn easy to create a simple server to pull my repos:

var https = require('https');  
var http = require('http');

http.createServer(function(request, response) {  
    console.log("Request handler 'codeplex' was called.");

    var options = {
      hostname: 'www.codeplex.com',
      path: '/api/users/aheidebrecht/projects',
      method: 'GET'
    };

    var req = https.request(options, function(res) {
        var json = '';
        res.on('data', function(d) {
            json += d;
        });

        res.on('end', function() {
            // this is just for display purposes... it is unformatted otherwise
            var str = JSON.stringify(JSON.parse(json), null, "    ");
            response.writeHead(200, { 'Content-Type': 'text/plain' });
            response.write(str);
            response.end();
        });
    });

    req.end();

    req.on('error', function(err) {
        console.error(err);

        response.writeHead(500, { 'Content-Type': 'text/plain' });
        response.write(err);
        response.end();
    });
}).listen(999);

Just running it in node, and I get the expected output:

[
    {
        "Role": "Owner",
        "Name": "wpfprogress",
        "Title": "WPF Background Progress Indicator",
        "Description": "The WPF Background Progress Indicator allows developers to show the application is busy without stopping the animation when the UI thread is busy. The indicator's appearance can be modified by using the BusyStyle property.",
        "Url": "https://wpfprogress.codeplex.com/",
        "IsPublished": true,
        "NumberOfFollowers": 12,
        "SourceControl": {
            "ServerType": "Mercurial",
            "Url": "https://hg.codeplex.com/wpfprogress"
        }
    },
    {
        "Role": "Owner",
        "Name": "codeonlystoredprocedures",
        "Title": "Code Only Stored Procedures",
        "Description": "A library for easily calling Stored Procedures. Works great with Entity Framework Code First models.",
        "Url": "https://codeonlystoredprocedures.codeplex.com/",
        "IsPublished": true,
        "NumberOfFollowers": 2,
        "SourceControl": {
            "ServerType": "Git",
            "Url": "https://git01.codeplex.com/codeonlystoredprocedures"
        }
    }
]

One of the cool things about codeplex is that you can use different source control providers, and you can see that I'm using both git and mercurial. Luckily, strider has support for both. Codeplex also supports TFS, so I may see if I can figure out a way to add that too, but it is low on my radar. As I am planning on turning this thing into a full fledged provider for strider in subsequent posts, I'm going to host it on github.

Here is the changeset at this point in the project.

-AH

Moving to ghost

As is obvious to the most casual of observers, I've never been the most prolific blogger. But, I have recently realized that I need to learn javascript (I can't stay a WPF developer my whole career if MS decides to stop updating it...). At least if I want to have... Read More