mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
--get-ready on built meteor now fails on error
Generally reorganize some silent/quiet/background flags to be more explicit about what is being show/hidden. The main point here is that the 'background updater' wants to show banners but ignore errors, whereas --get-ready wants to show errors but not banners.
This commit is contained in:
@@ -126,7 +126,7 @@ main.registerCommand({
|
||||
}, function (options) {
|
||||
if (files.usesWarehouse()) {
|
||||
var updater = require('./updater.js');
|
||||
updater.tryToDownloadUpdate(true /* silent */);
|
||||
updater.tryToDownloadUpdate();
|
||||
} else {
|
||||
// dev bundle is downloaded by the wrapper script. We just need
|
||||
// to install NPM dependencies.
|
||||
@@ -326,7 +326,7 @@ main.registerCommand({
|
||||
// #UpdateSpringboard), go get the latest release and switch to it.
|
||||
if (! release.forced) {
|
||||
try {
|
||||
warehouse.fetchLatestRelease();
|
||||
warehouse.fetchLatestRelease({showInstalling: true});
|
||||
} catch (e) {
|
||||
if (! (e instanceof files.OfflineError)) {
|
||||
console.error("Failed to update Meteor.");
|
||||
|
||||
@@ -13,22 +13,32 @@ var Updater = function () {
|
||||
_.extend(Updater.prototype, {
|
||||
start: function () {
|
||||
var self = this;
|
||||
var updater = require('./updater.js');
|
||||
|
||||
if (self.timer)
|
||||
throw new Error("already running?");
|
||||
|
||||
// Check twice a day.
|
||||
self.timer = setInterval(inFiber(function () {
|
||||
updater.tryToDownloadUpdate(/* silent */ false);
|
||||
self._check();
|
||||
}), 12*60*60*1000);
|
||||
|
||||
// Also start a check now, but don't block on it.
|
||||
new Fiber(function () {
|
||||
updater.tryToDownloadUpdate(/* silent */ false);
|
||||
self._check();
|
||||
}).run();
|
||||
},
|
||||
|
||||
_check: function () {
|
||||
var self = this;
|
||||
var updater = require('./updater.js');
|
||||
try {
|
||||
updater.tryToDownloadUpdate({showBanner: true});
|
||||
} catch (e) {
|
||||
// oh well, this was the background. no need to show any errors.
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
||||
// Returns immediately. However if an update check is currently
|
||||
// running it will complete in the background. Idempotent.
|
||||
stop: function () {
|
||||
|
||||
@@ -30,21 +30,22 @@ exports.getManifest = function () {
|
||||
* Check to see if an update is available. If so, download and install
|
||||
* it before returning.
|
||||
*
|
||||
* If 'silent' is true, suppress chatter.
|
||||
* options: showBanner
|
||||
*/
|
||||
var checkInProgress = false;
|
||||
exports.tryToDownloadUpdate = function (silent) {
|
||||
exports.tryToDownloadUpdate = function (options) {
|
||||
options = options || {};
|
||||
// Don't run more than one check simultaneously. It should be
|
||||
// harmless but having two downloads happening simultaneously (and
|
||||
// two sets of messages being printed) would be confusing.
|
||||
if (checkInProgress)
|
||||
return;
|
||||
checkInProgress = true;
|
||||
check(silent);
|
||||
check(!!options.showBanner);
|
||||
checkInProgress = false;
|
||||
};
|
||||
|
||||
var check = function (silent) {
|
||||
var check = function (showBanner) {
|
||||
var manifest = null;
|
||||
try {
|
||||
manifest = exports.getManifest();
|
||||
@@ -68,7 +69,7 @@ var check = function (silent) {
|
||||
// the last release which has had a banner printed.)
|
||||
if (manifest.releases.stable.banner &&
|
||||
warehouse.lastPrintedBannerRelease() !== manifestLatestRelease) {
|
||||
if (! silent) {
|
||||
if (showBanner) {
|
||||
console.log();
|
||||
console.log(manifest.releases.stable.banner);
|
||||
console.log();
|
||||
@@ -76,22 +77,17 @@ var check = function (silent) {
|
||||
warehouse.writeLastPrintedBannerRelease(manifestLatestRelease);
|
||||
} else {
|
||||
// Already printed this banner, or maybe there is no banner.
|
||||
if (! silent) {
|
||||
if (showBanner) {
|
||||
console.log("=> Meteor %s is being downloaded in the background.",
|
||||
manifestLatestRelease);
|
||||
}
|
||||
}
|
||||
try {
|
||||
warehouse.fetchLatestRelease(true /* background */);
|
||||
} catch (e) {
|
||||
// oh well, this was the background. no need to show any errors.
|
||||
return;
|
||||
}
|
||||
warehouse.fetchLatestRelease({showInstalling: showBanner});
|
||||
// We should now have fetched the latest release, which *probably* is
|
||||
// manifestLatestRelease. As long as it's changed from the one it was
|
||||
// before we tried to fetch it, print that out.
|
||||
var newLatestRelease = warehouse.latestRelease();
|
||||
if (newLatestRelease !== localLatestRelease && ! silent) {
|
||||
if (showBanner && newLatestRelease !== localLatestRelease) {
|
||||
console.log(
|
||||
"=> Meteor %s is available. Update this project with 'meteor update'.",
|
||||
newLatestRelease);
|
||||
@@ -103,9 +99,9 @@ var check = function (silent) {
|
||||
// update this app? Specifically: is our local latest release something
|
||||
// other than this app's release, and the user didn't specify a specific
|
||||
// release at the command line with --release?
|
||||
if (localLatestRelease !== release.current.name &&
|
||||
! release.forced &&
|
||||
! silent) {
|
||||
if (showBanner &&
|
||||
localLatestRelease !== release.current.name &&
|
||||
! release.forced) {
|
||||
console.log(
|
||||
"=> Meteor %s is available. Update this project with 'meteor update'.",
|
||||
localLatestRelease);
|
||||
|
||||
@@ -91,7 +91,7 @@ _.extend(warehouse, {
|
||||
var manifestPath = path.join(
|
||||
warehouse.getWarehouseDir(), 'releases', release + '.release.json');
|
||||
|
||||
return warehouse._populateWarehouseForRelease(release, quiet);
|
||||
return warehouse._populateWarehouseForRelease(release, !quiet);
|
||||
},
|
||||
|
||||
_latestReleaseSymlinkPath: function () {
|
||||
@@ -127,7 +127,8 @@ _.extend(warehouse, {
|
||||
|
||||
// returns true if we updated the latest symlink
|
||||
// XXX make errors prettier
|
||||
fetchLatestRelease: function (background) {
|
||||
fetchLatestRelease: function (options) {
|
||||
options = options || {};
|
||||
var manifest = updater.getManifest();
|
||||
|
||||
// XXX in the future support release channels other than stable
|
||||
@@ -136,8 +137,8 @@ _.extend(warehouse, {
|
||||
if (! releaseName)
|
||||
throw new Error("no stable release found?");
|
||||
|
||||
var latestReleaseManifest =
|
||||
warehouse._populateWarehouseForRelease(releaseName, background);
|
||||
var latestReleaseManifest = warehouse._populateWarehouseForRelease(
|
||||
releaseName, !!options.showInstalling);
|
||||
|
||||
// First, make sure the latest tools symlink reflects the latest installed
|
||||
// release.
|
||||
@@ -221,7 +222,7 @@ _.extend(warehouse, {
|
||||
// fetches the manifest file for the given release version. also fetches
|
||||
// all of the missing versioned packages referenced from the release manifest
|
||||
// @param releaseVersion {String} eg "0.1"
|
||||
_populateWarehouseForRelease: function (releaseVersion, background) {
|
||||
_populateWarehouseForRelease: function (releaseVersion, showInstalling) {
|
||||
var future = new Future;
|
||||
var releasesDir = path.join(warehouse.getWarehouseDir(), 'releases');
|
||||
files.mkdir_p(releasesDir, 0755);
|
||||
@@ -271,7 +272,7 @@ _.extend(warehouse, {
|
||||
if (releaseAlreadyExists && !newPieces)
|
||||
return releaseManifest;
|
||||
|
||||
if (newPieces && !background) {
|
||||
if (newPieces && showInstalling) {
|
||||
console.log("Installing Meteor %s:", releaseVersion);
|
||||
if (newPieces.tools) {
|
||||
console.log(" * 'meteor' build tool (version %s)",
|
||||
@@ -292,7 +293,7 @@ _.extend(warehouse, {
|
||||
warehouse._platform(),
|
||||
warehouse.getWarehouseDir());
|
||||
} catch (e) {
|
||||
if (!background)
|
||||
if (showInstalling)
|
||||
console.error("Failed to load tools for release " + releaseVersion);
|
||||
throw e;
|
||||
}
|
||||
@@ -309,7 +310,7 @@ _.extend(warehouse, {
|
||||
warehouse._platform(),
|
||||
warehouse.getWarehouseDir());
|
||||
} catch (e) {
|
||||
if (!background)
|
||||
if (showInstalling)
|
||||
console.error("Failed to load packages for release " +
|
||||
releaseVersion);
|
||||
throw e;
|
||||
@@ -337,9 +338,9 @@ _.extend(warehouse, {
|
||||
}
|
||||
|
||||
// Finally, clear the "fresh" files for all the things we just printed
|
||||
// (whether or not we just downloaded them), unless we were in the
|
||||
// background and printed nothing.
|
||||
if (newPieces && !background) {
|
||||
// (whether or not we just downloaded them). (Don't do this if we didn't
|
||||
// print the installing message!)
|
||||
if (newPieces && showInstalling) {
|
||||
if (newPieces.tools) {
|
||||
fs.unlinkSync(warehouse.getToolsFreshFile(newPieces.tools.version));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user