From fc3b3fd7c4ba5814722f919b08f352dd21b481fd Mon Sep 17 00:00:00 2001 From: David Glasser Date: Tue, 6 May 2014 16:41:20 -0700 Subject: [PATCH] Reorder meteor publish Now we don't create records on the server for things that don't build --- tools/commands.js | 96 ++++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 46 deletions(-) diff --git a/tools/commands.js b/tools/commands.js index 46a194437f..76c99b2ca6 100644 --- a/tools/commands.js +++ b/tools/commands.js @@ -1637,6 +1637,19 @@ main.registerCommand({ // submissions before they ever hit the wire. catalog.refresh(true); + try { + var conn = packageClient.loggedInPackagesConnection(); + } catch (err) { + packageClient.handlePackageServerConnectionError(err); + return 1; + } + if (! conn) { + process.stderr.write('No connection: Publish failed\n'); + return 1; + } + + process.stdout.write('Building package...\n'); + // XXX Prettify error messages var packageSource, compileResult; @@ -1692,17 +1705,44 @@ main.registerCommand({ return 1; } - try { - var conn = packageClient.loggedInPackagesConnection(); - } catch (err) { - packageClient.handlePackageServerConnectionError(err); - return 1; - } - if (! conn) { - process.stderr.write('No connection: Publish failed\n'); + // We need to build the test package to get all of its sources. + var testFiles = []; + messages = buildmessage.capture( + { title: "getting test sources" }, + function () { + var testName = packageSource.testName; + if (testName) { + var testSource = new PackageSource; + testSource.initFromPackageDir(testName, options.packageDir); + if (buildmessage.jobHasMessages()) + return; // already have errors, so skip the build + + var testUnipackage = compiler.compile(testSource, { officialBuild: true }); + testFiles = testUnipackage.sources; + } + }); + + if (messages.hasMessages()) { + process.stdout.write(messages.formatMessages()); return 1; } + process.stdout.write('Bundling source...\n'); + + // XXX prevent people from directly publishing meteor-tool outside of the + // release publishing process (since we don't automatically rebuild the tool + // package) + + var sources = _.union(compileResult.sources, testFiles); + + // Send the versions lock file over to the server! We should make sure to use + // the same version lock file when we build this source elsewhere (ex: + // publish-for-arch). + sources.push(packageSource.versionsFileName()); + var bundleResult = packageClient.bundleSource(compileResult.unipackage, + sources, + options.packageDir); + // Create the package. // XXX First sync package metadata and check if it exists. if (options.create) { @@ -1727,44 +1767,6 @@ main.registerCommand({ // telling them to try 'meteor publish-for-arch' if they want to // publish a new build. - process.stdout.write('Bundling source...\n'); - - // We need to build the test package to get all of its sources. - var testFiles = []; - messages = buildmessage.capture( - { title: "getting test sources" }, - function () { - var testName = packageSource.testName; - if (testName) { - var testSource = new PackageSource; - testSource.initFromPackageDir(testName, options.packageDir); - if (buildmessage.jobHasMessages()) - return; // already have errors, so skip the build - - var testUnipackage = compiler.compile(testSource, { officialBuild: true }); - testFiles = testUnipackage.sources; - } - }); - - if (messages.hasMessages()) { - process.stdout.write(messages.formatMessages()); - return 1; - } - - // XXX prevent people from directly publishing meteor-tool outside of the - // release publishing process (since we don't automatically rebuild the tool - // package) - - var sources = _.union(compileResult.sources, testFiles); - - // Send the versions lock file over to the server! We should make sure to use - // the same version lock file when we build this source elsewhere (ex: - // publish-for-arch). - sources.push(packageSource.versionsFileName()); - var bundleResult = packageClient.bundleSource(compileResult.unipackage, - sources, - options.packageDir); - process.stdout.write('Uploading source...\n'); packageClient.uploadTarball(uploadInfo.uploadUrl, bundleResult.sourceTarball); @@ -1776,6 +1778,8 @@ main.registerCommand({ packageClient.createAndPublishBuiltPackage(conn, compileResult.unipackage, options.packageDir); + catalog.refresh(true); + return 0; });