exports.CURRENT_VERSION = "0.5.3";

var fs = require("fs");
var http = require("http");
var https = require("https");
var path = require("path");
var semver = require("semver");

var files = require(path.join(__dirname, 'files.js'));

var manifest_options = {
/* uncomment for testing
  host: 's3.amazonaws.com',
  path: '/com.meteor.static/test/update/manifest.json'
*/
  host: 'update.meteor.com',
  path: '/manifest.json'
};


/**
 * Downloads the current manifest file and returns it via a callback (or
 * null on error)
 */
exports.get_manifest = function (callback) {
  var req = https.request(manifest_options, function(res) {
    if (res.statusCode !== 200) {
      callback(null);
      return;
    }
    res.setEncoding('utf8');
    var manifest = '';
    res.on('data', function (chunk) {
      manifest = manifest + chunk;
    });
    res.on('end', function () {
      var parsed;
      try {
        parsed = JSON.parse(manifest);
      } catch (err) {
        parsed = null;
      };
      callback(parsed);
    });
  });
  req.addListener('error', function (err) {
    // Need to register an error handler or node will crash:
    // http://rentzsch.tumblr.com/post/664884799/node-js-handling-refused-http-client-connections

    callback(null);
  });
  req.end();
};

/**
 * Takes a version string (or a manifest object) and returns true if
 * this copy is out of date.
 */
exports.needs_upgrade = function (version) {
  if (version && typeof version !== "string") {
    version = version.version;
  }
  if (!version) return false;

  return semver.lt(exports.CURRENT_VERSION, version);
};


exports.git_sha = function () {
  var d = files.get_dev_bundle();
  var f = path.join(d, ".git_version.txt");

  if (fs.existsSync(f)) {
    try {
      var contents = fs.readFileSync(f, 'utf8');
      contents = contents.replace(/\s+$/, "");
      return contents;
    } catch (err) { }
  }

  return null;
};

@@ -1,29 +1,265 @@
-exports.CURRENT_VERSION =
+// During automated QA of the updater, modify this file to set testingUpdater to%0A// true. This will make it act as if it is at version 0.1.0 and use test URLs%0A// for update checks.%0Avar testingUpdater = false;%0Aexports.CURRENT_VERSION = testingUpdater ? %220.1.0%22 :
  %220.
@@ -491,34 +491,26 @@
 s = 
-%7B%0A/* uncomment for testing
+testingUpdater ? %7B
 %0A  h
@@ -589,18 +589,21 @@
 t.json'%0A
-*/
+%7D : %7B
 %0A  host:

Make the modification needed for testing the updater simpler.