diff --git a/tools/catalog.js b/tools/catalog.js index 78a516f76c..bab3133b55 100644 --- a/tools/catalog.js +++ b/tools/catalog.js @@ -16,6 +16,9 @@ var config = require('./config.js'); var packageClient = require('./package-client.js'); var Console = require('./console.js').Console; +// XXX: Circular? +var main = require("./main.js"); + var catalog = exports; catalog.refreshFailed = undefined; @@ -30,7 +33,14 @@ catalog.Refresh.OnceAtStart = function (options) { catalog.Refresh.OnceAtStart.prototype.beforeCommand = function () { var self = this; - catalog.refreshOrWarn(self.options); + if (!catalog.refreshOrWarn(self.options)) { + if (self.options.ignoreFailure) { + Console.debug("Failed to update package catalog, but will continue."); + } else { + Console.error("This command requires an up-to-date package catalog. Exiting."); + throw main.ExitWithCode(1); + } + } }; // Refresh strategy: never (we don't use the package catalog) diff --git a/tools/commands-packages.js b/tools/commands-packages.js index aacbd21ed9..c2343d9a07 100644 --- a/tools/commands-packages.js +++ b/tools/commands-packages.js @@ -145,7 +145,7 @@ var formatArchitecture = function (s) { // necessary! main.registerCommand({ name: '--get-ready', - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: false }) }, function (options) { // It is not strictly needed, but it is thematically a good idea to refresh // the official catalog when we call get-ready, since it is an @@ -220,7 +220,7 @@ main.registerCommand({ 'top-level': { type: Boolean } }, requiresPackage: true, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: false }) }, function (options) { if (options.create && options['existing-version']) { // Make up your mind! @@ -373,7 +373,7 @@ main.registerCommand({ name: 'publish-for-arch', minArgs: 1, maxArgs: 1, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: false }) }, function (options) { // argument processing var all = options.args[0].split('@'); @@ -616,7 +616,7 @@ main.registerCommand({ 'create-track': { type: Boolean, required: false }, 'from-checkout': { type: Boolean, required: false } }, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: false }) }, function (options) { // Refresh the catalog, cacheing the remote package data on the server. //Console.info("Resyncing with package server..."); @@ -1130,7 +1130,7 @@ main.registerCommand({ options: { "show-old": {type: Boolean, required: false } }, - catalogRefresh: new catalog.Refresh.OnceAtStart({ maxAge: DEFAULT_MAX_AGE }) + catalogRefresh: new catalog.Refresh.OnceAtStart({ maxAge: DEFAULT_MAX_AGE, ignoreErrors: true }) }, function (options) { // We should refresh the catalog in case there are new versions. //refreshOfficialCatalogOrDie({ maxAge: DEFAULT_MAX_AGE }); @@ -1290,7 +1290,7 @@ main.registerCommand({ main.registerCommand({ name: 'refresh', pretty: true, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: false }) }, function (options) { //refreshOfficialCatalogOrDie(); }); @@ -1307,7 +1307,7 @@ main.registerCommand({ // Undocumented debug-only option for Velocity. "debug-only": {type: Boolean, required: false} }, - catalogRefresh: new catalog.Refresh.OnceAtStart({ maxAge: DEFAULT_MAX_AGE }) + catalogRefresh: new catalog.Refresh.OnceAtStart({ maxAge: DEFAULT_MAX_AGE, ignoreErrors: true }) }, function (options) { if (options.args.length === 0) { Console.info("To show all packages, do", Console.command("meteor search .")); @@ -1454,7 +1454,7 @@ main.registerCommand({ requiresApp: true, options: { }, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: true }) }, function (options) { var items = []; @@ -1850,7 +1850,7 @@ main.registerCommand({ requiresRelease: false, minArgs: 0, maxArgs: Infinity, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: true }) }, function (options) { // Refresh the catalog, cacheing the remote package data on the server. // XXX should be able to update even without a refresh, esp to a specific @@ -1992,7 +1992,7 @@ main.registerCommand({ maxArgs: Infinity, requiresApp: true, pretty: true, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: true }) }, function (options) { // Special case on reserved package namespaces, such as 'cordova' @@ -2067,6 +2067,7 @@ main.registerCommand({ }); if (messages.hasMessages()) { Console.printMessages(messages); + explainIfRefreshFailed(); return 1; } @@ -2162,6 +2163,8 @@ main.registerCommand({ // different result than what they are going to get. We have already logged an // error, so we should exit. if ( failed ) { + explainIfRefreshFailed(); + return 1; } @@ -2183,6 +2186,7 @@ main.registerCommand({ if ( ! newVersions) { // XXX: Better error handling. Console.error("Cannot resolve package dependencies."); + explainIfRefreshFailed(); return; } @@ -2203,10 +2207,12 @@ main.registerCommand({ Console.error( "Could not satisfy all the specified constraints:\n" + e + ""); + explainIfRefreshFailed(); return 1; } if (messages.hasMessages()) { Console.printMessages(messages); + explainIfRefreshFailed(); return 1; } @@ -2240,7 +2246,7 @@ main.registerCommand({ minArgs: 1, maxArgs: Infinity, requiresApp: true, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: true }) }, function (options) { // Special case on reserved package namespaces, such as 'cordova' var filteredPackages = cordova.filterPackages(options.args); @@ -2336,7 +2342,7 @@ main.registerCommand({ remove: { type: String, short: "r" }, list: { type: Boolean } }, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: false }) }, function (options) { // We want the most recent information. @@ -2431,7 +2437,7 @@ main.registerCommand({ // In this function, we want to use the official catalog everywhere, because // we assume that all packages have been published (along with the release // obviously) and we want to be sure to only bundle the published versions. - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: false }) }, function (options) { var releaseNameAndVersion = options.args[0]; var outputDirectory = options.args[1]; @@ -2603,7 +2609,7 @@ main.registerCommand({ minArgs: 1, maxArgs: 1, hidden: true, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: false }) }, function (options) { var bannersFile = options.args[0]; try { @@ -2651,7 +2657,7 @@ main.registerCommand({ options: { unrecommend: { type: Boolean, short: "u" } }, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: false }) }, function (options) { // We want the most recent information. @@ -2705,7 +2711,7 @@ main.registerCommand({ name: 'admin set-earliest-compatible-version', minArgs: 2, maxArgs: 2, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: false }) }, function (options) { // We want the most recent information. @@ -2756,7 +2762,7 @@ main.registerCommand({ name: 'admin change-homepage', minArgs: 2, maxArgs: 2, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: false }) }, function (options) { // We want the most recent information. @@ -2803,7 +2809,7 @@ main.registerCommand({ "success" : {type: Boolean, required: false} }, hidden: true, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: false }) }, function (options) { // We don't care about having the most recent information, but we do want the @@ -2861,7 +2867,7 @@ main.registerCommand({ "tag" : {type: String, required: false} }, hidden: true, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: false }) }, function (options) { if (options.commit && options.tag) diff --git a/tools/commands.js b/tools/commands.js index 0f91116b67..13c96b15b1 100644 --- a/tools/commands.js +++ b/tools/commands.js @@ -179,7 +179,7 @@ var runCommandOptions = { // and does not monitor for file changes. Not for end-user use. clean: { type: Boolean} }, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: true }) }; main.registerCommand(_.extend( @@ -385,7 +385,7 @@ main.registerCommand({ package: { type: Boolean } }, pretty: true, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: true }) }, function (options) { // Creating a package is much easier than creating an app, so if that's what @@ -622,7 +622,7 @@ var buildCommands = { "mobile-port": { type: String }, verbose: { type: Boolean, short: "v" } }, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: true }) }; main.registerCommand(_.extend({ name: 'build' }, buildCommands), @@ -967,7 +967,7 @@ main.registerCommand({ requiresApp: function (options) { return options.delete || options.star ? false : true; }, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: true }) }, function (options) { var site = qualifySitename(options.args[0]); config.printUniverseBanner(); @@ -1249,7 +1249,7 @@ main.registerCommand({ android: { type: Boolean }, 'android-device': { type: Boolean } }, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: true }) }, function (options) { try { var parsedUrl = utils.parseUrl(options.port); @@ -1567,7 +1567,7 @@ main.registerCommand({ name: 'rebuild', maxArgs: Infinity, hidden: true, - catalogRefresh: new catalog.Refresh.OnceAtStart() + catalogRefresh: new catalog.Refresh.OnceAtStart({ ignoreErrors: true }) }, function (options) { var messages; var count = 0; diff --git a/tools/main.js b/tools/main.js index c196a28384..6ba561b355 100644 --- a/tools/main.js +++ b/tools/main.js @@ -1304,14 +1304,9 @@ commandName + ": You're not in a Meteor project directory.\n" + // Before run, do a package sync if one is configured var catalogRefreshStrategy = command.catalogRefresh; if (!alreadyRefreshed && catalogRefreshStrategy.beforeCommand) { - // XXX This buildmessage.capture only exists for showing progress. - var messages = buildmessage.capture({title: 'Updating package catalog'}, function () { + buildmessage.enterJob({title: 'Updating package catalog'}, function () { catalogRefreshStrategy.beforeCommand(); }); - if (messages.hasMessages()) { - Console.printMessages(messages); - throw main.ExitWithCode(1); - } } var ret = command.func(options);