Skip to content

Commit

Permalink
Add a way to specify 1.1 pre-releases as recommended
Browse files Browse the repository at this point in the history
Any pre-release published with a "win" in the pre-release section will be
treated as recommended by the 1.1 pre-release tool.
  • Loading branch information
Sashko Stubailo committed Mar 5, 2015
1 parent 2080923 commit e2fd3ae
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 26 deletions.
61 changes: 52 additions & 9 deletions tools/catalog-remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -805,23 +805,29 @@ _.extend(RemoteCatalog.prototype, {
// track, sorted by their orderKey. Returns the empty array if the release
// track does not exist or does not have any recommended versions.
getSortedRecommendedReleaseRecords: function (track, laterThanOrderKey) {
var allRecords = this.getSortedReleaseRecords(track, laterThanOrderKey);

return _.where(allRecords, { recommended: true });
},

getSortedReleaseRecords: function (track, laterThanOrderKey) {
var self = this;
// XXX releaseVersions content objects are kinda big; if we put
// 'recommended' and 'orderKey' in their own columns this could be faster
var result = self._contentQuery(
"SELECT content FROM releaseVersions WHERE track=?", track);

var recommended = _.filter(result, function (v) {
if (!v.recommended)
return false;
var laterThan = _.filter(result, function (v) {
return !laterThanOrderKey || v.orderKey > laterThanOrderKey;
});

var recSort = _.sortBy(recommended, function (rec) {
var sorted = _.sortBy(laterThan, function (rec) {
return rec.orderKey;
});
recSort.reverse();
return recSort;

sorted.reverse();

return sorted;
},

// Given a release track, returns all version records for this track.
Expand Down Expand Up @@ -854,13 +860,50 @@ _.extend(RemoteCatalog.prototype, {
getDefaultReleaseVersionRecord: function (track) {
var self = this;

if (!track)
if (! track)
track = exports.DEFAULT_TRACK;

var versions = self.getSortedRecommendedReleaseRecords(track);
if (!versions.length)
if (! versions.length)
return null;
return versions[0];

var releaseVersionRecord = versions[0];

if (process.platform === "win32") {
// For a short while, there won't be any recommended releases that work on
// Windows.
//
// XXX this whole special case block can be removed once the first
// recommended release for Windows comes out.
var hasBuildForWindows = catalog.official.getBuildsForArches(
releaseVersionRecord.track, releaseVersionRecord.version,
[archinfo.host()]);

if (! hasBuildForWindows) {
// If the newest recommended release doesn't work on Windows, we should
// resort to a hacky strategy around version naming.
//
// Versions named [email protected].# will be treated as recommended;
// Versions with any other string instead of `win` in that location
// will not be treated as recommended.

var allRecords = self.getSortedReleaseRecords(track);

for (var i = 0; i < allRecords.length; i++) {
var parsedVersion = VersionParser.parse(allRecords[i].version);

if (parsedVersion.prerelease[0] === "win") {
return allRecords[i];
}
}

// We should never get here since there should always be at least one
// version that matches.
throw new Error("couldn't find a release compatible with Windows.");
}
}

return releaseVersionRecord;
},

getBuildWithPreciseBuildArchitectures: function (versionRecord, buildArchitectures) {
Expand Down
39 changes: 22 additions & 17 deletions tools/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,23 @@ var springboard = function (rel, options) {
versionMap[toolsPkg] = toolsVersion;
var packageMap = new packageMapModule.PackageMap(versionMap);

if (process.platform === "win32") {
// Make sure the tool we are trying to download has been built for Windows
var buildsForHostArch = catalog.official.getBuildsForArches(
rel.getToolsPackage(), rel.getToolsVersion(), [archinfo.host()]);

if (! buildsForHostArch) {
var release = catalog.official.getDefaultReleaseVersion();
var releaseName = release.track + "@" + release.version;

Console.error(
"This project uses " + rel.getDisplayName() + ", which isn't",
"available on Windows. To work with this app on all supported",
"platforms, use", Console.command("meteor update --release " + releaseName),
"to pin this app to the newest Windows-compatible release.");
}
}

// XXX split better
Console.withProgressDisplayVisible(function () {
var messages = buildmessage.capture(
Expand All @@ -413,27 +430,15 @@ var springboard = function (rel, options) {
});
}
);

if (messages.hasMessages()) {
// We have failed to download the tool that we are supposed to springboard
// to! That's bad. Let's exit.
if (options.fromApp) {
if (process.platform === "win32") {
// XXX improve this message for real release
var release = catalog.official.getDefaultReleaseVersion();
var releaseName = release.track + "@" + release.version;

Console.error(
"This project uses " + rel.getDisplayName() + ", which isn't",
"available on Windows. To work with this app on all platforms, use",
Console.command("meteor update --release " + releaseName),
"to pin this app to the newest Windows preview release.");
} else {
Console.error(
"Sorry, this project uses " + rel.getDisplayName() + ", which is",
"not installed and could not be downloaded. Please check to make",
"sure that you are online.");
}

Console.error(
"Sorry, this project uses " + rel.getDisplayName() + ", which is",
"not installed and could not be downloaded. Please check to make",
"sure that you are online.");
} else {
Console.error(
"Sorry, " + rel.getDisplayName() + " is not installed and could not",
Expand Down

0 comments on commit e2fd3ae

Please sign in to comment.