keep releases in catalog

This commit is contained in:
ekatek
2014-05-05 14:56:44 -07:00
parent 2eac771902
commit 6d7e097fc0
2 changed files with 69 additions and 2 deletions

View File

@@ -42,6 +42,8 @@ var Catalog = function () {
self.packages = null;
self.versions = null;
self.builds = null;
self.releaseTracks = null;
self.releaseVersions = null;
// Local directories to search for package source trees
self.localPackageDirs = null;
@@ -107,6 +109,8 @@ _.extend(Catalog.prototype, {
self.packages = [];
self.versions = [];
self.builds = [];
self.releaseTracks = [];
self.releaseVersions = [];
self._addLocalPackageOverrides(true /* setInitialized */);
// Now we can include options.localPackageDirs. We do this
@@ -162,6 +166,8 @@ _.extend(Catalog.prototype, {
self.packages = [];
self.versions = [];
self.builds = [];
self.releaseTracks = [];
self.releaseVersions = [];
if (allPackageData) {
self._insertServerPackages(allPackageData);
}
@@ -482,6 +488,8 @@ _.extend(Catalog.prototype, {
self.packages.push.apply(self.packages, serverPackageData.packages);
self.versions.push.apply(self.versions, serverPackageData.versions);
self.builds.push.apply(self.builds, serverPackageData.builds);
self.releaseTracks.push.apply(self.releaseTracks, serverPackageData.releaseTracks);
self.releaseVersions.push.apply(self.releaseVersions, serverPackageData.releaseVersions);
},
_requireInitialized: function () {
@@ -636,6 +644,50 @@ _.extend(Catalog.prototype, {
return null;
},
// Returns general (non-version-specific) information about a
// release track, or null if there is no such release track.
getReleaseTrack: function (name) {
var self = this;
self._requireInitialized();
return _.findWhere(self.releaseTrack, { name: name });
},
// Return information about a particular release version, or null if such
// release version does not exist.
getReleaseVersion: function (name, version) {
var self = this;
self._requireInitialized();
var versionRecord = _.findWhere(self.releaseVersions,
{ name: name, version: version });
if (!versionRecord) {
return null;
}
return versionRecord;
},
// Return an array with the names of all of the release tracks that we know
// about, in no particular order.
getAllReleaseTracks: function () {
var self = this;
self._requireInitialized();
return _.pluck(self.releaseTracks, 'name');
},
// Given a release track, returns an array of the versions available for this
// track, in no particular order. Returns the empty array if the release
// doesn't exist or doesn't have any versions.
getReleaseVersions: function (name) {
var self = this;
self._requireInitialized();
var ret = _.pluck(_.where(self.releaseVersions, { name: name }),
'version');
return ret;
},
// Return an array with the names of all of the packages that we
// know about, in no particular order.
getAllPackageNames: function () {

View File

@@ -862,7 +862,8 @@ main.registerCommand({
return options.using;
},
options: {
using: { type: Boolean }
using: { type: Boolean },
releases: { type: Boolean }
}
}, function (options) {
var items = [];
@@ -873,7 +874,21 @@ main.registerCommand({
// future, we should move this call to sync somewhere in the background.
catalog.refresh(true);
if (options.using) {
if (options.releases && options.using) {
console.log("XXX: The contents of your release file.");
} else if (options.releases) {
// XXX: We probably want the recommended version rather than all of them,
// but for now, let's just display some stuff to make sure that it worked.
_.each(catalog.getAllReleaseTracks(), function (name) {
var versions = catalog.getReleaseVersions(name);
_.each(versions, function (version) {
var versionInfo = catalog.getReleaseVersion(name, version);
if (versionInfo) {
items.push({ name: name + " " + version, description: versionInfo.description });
}
});
});
} else if (options.using) {
// Generate a package loader for this project. This will also compute the
// nessessary versions and write them to disk.
project.generatePackageLoader(options.appDir);