airportyh/saucelauncher — pull request #4 by unindented (2013-04-30 23:38:56+00:00)
Title: Revamp saucelauncher

Sorry for the huge commit, accidentally lost my history...

Anyways, this is a pull request to try and take *saucelauncher* more seriously.

Stuff I've added:
- Separation of concerns: I've broken all the logic that was inside cli.js into separate modules.
- Tests: Most modules are now pretty well tested (if you have `jscoverage` installed, run `make coverage` and open `coverage.html` to check it out).
- Smarter resolution of browser name: It tries to guess a supported browser from the string provided by the user.
- Better handling of tunnel process: Now it waits until `Sauce-Connect.jar` has cleaned after itself before finishing the process.
- New `jobs` and `tunnels` commands: They list your last 100 jobs and your open tunnels respectively.

Some controversial decisions:
- Use `node-sandbox-module` to stub out dependencies in tests: It complicates test setup quite a lot, but it was the only way I could think of to keep the tests fast.
- Rename `tunnel` to `create-tunnel`: I added a `tunnels` command, so having another command called `tunnel` seemed confusing. If at some point we add functionality to update or stop workers, it would be easy to follow this line of naming (`update-worker`, `stop-worker`, etc).
- Remove options from `launch` that were not being used: `timeout`, `attach`, etc. If and when they are needed, they can be added back.
- Change the way browser and platform are specified: Instead of having separate parameters, now you just say `launch firefox-20-windows2008 http://www.google.com`, and it will try to extract necessary information from that string.
- Use levenshtein distance to guess what browser the user actually wants: We have the list of supported browsers, so why not try and find the closest match for what the user specified. I'm using levenshtein, which is not optimal, but works reasonably well. This logic is isolated in the `BrowserMatcher` module, so if we want to change it in the future it should be easy.

I'm probably missing some stuff... Feel free to discuss anything. Thank you!