appharbor/appharbor-cli — pull request #14 by ido-ran (2013-06-28 13:09:36+00:00)
Title: Add support for deploying application from CI server

I use Jenkins as CI server. As I move to AppHarbor I need a way to automate the deployment of my web-application to AppHarbor.
AppHarbor CLI was designed to be used by human and this change allow machine to use it too.

There are several changes:
1. I've add to the DeployAppCommand two parameters to accept the username and password from the console. This allow to run the command with apriori login manually. It also does not store the login token and allow two or more deployment at the same time on the same machine with the same user (the way CI usually works).

2. I've added some print outs to allow me to understand what happen by reading the CI log.

3. The source-directory parameter did not take into account the fact that the Tar library use the current working directory as a reference when creating the tar entries. This cause the resulting Tar file to has the source-directory prefixed to all the file names which result in bad deployment in AppHarbor. For example, if you run the command from c:\deploy and you have the file c:\deploy\a\b\image.png and you use source-directory=a\b the result tar file when extracted to c:\temp will be c:\temp\a\b\image.png instead of c:\temp\image.png.

3. I bump the version number so it will be easy to distinguish between old and new exe files.

4. Last but not least, during the executing of deploy app command you show progress bar in the console. This does not work well in CI servers which redirect the output and have no console window.
For now I've create a progress bar factory that check if a console window exist and either create the real console progress bar or a "null" NOP one. I didn't use DI because the progress bar was instantiated in a static method as well as inside the command. A better solution will be to register the correct progress bar implementation when the application starts.

I think it worth spending the time to separate the actual work of deploying from the informative output. I though of creating a "status update" interface for the deploy command and pass it in as a dependency. This way we could decide how to implement the update of which user is been used and how to implement the progress bar.
That's been said, this is a working version that I am currently use in my Jenkins server.