PackageMap only has a local (not layered) catalog

No need to introduce the LayeredCatalog anywhere it's not needed.

Simplify some more things about LayeredCatalog:

- remove unused containingCatalog link from localCatalog to
  layeredCatalog

- because of that, simplify LayeredCatalog initialization to occur after
  localCatalog (no more circular references required)

- drop some other dead LayeredCatalog methods
This commit is contained in:
David Glasser
2014-12-09 18:43:25 -08:00
parent 31a43fc019
commit d3ff3954bf
4 changed files with 13 additions and 38 deletions

View File

@@ -26,7 +26,6 @@ var LocalCatalog = function (options) {
self.packages = {};
self.initialized = false;
self.containingCatalog = options.containingCatalog || self;
// Local directories to search for package source trees
self.localPackageSearchDirs = null;

View File

@@ -105,14 +105,14 @@ var ACCEPT_NON_EMPTY = function (result) {
};
// The LayeredCatalog provides a way to query multiple catalogs in a uniform way
// A LayeredCatalog typically contains:
// A LayeredCatalog contains:
// - a local catalog referencing the packages of the project
// - a reference to the official catalog
var LayeredCatalog = function() {
var LayeredCatalog = function (localCatalog, otherCatalog) {
var self = this;
self.localCatalog = null;
self.otherCatalog = null;
self.localCatalog = localCatalog;
self.otherCatalog = otherCatalog;
};
_.extend(LayeredCatalog.prototype, {
@@ -121,12 +121,6 @@ _.extend(LayeredCatalog.prototype, {
return "LayeredCatalog []";
},
setCatalogs: function(local, remote) {
var self = this;
self.localCatalog = local;
self.otherCatalog = remote;
},
getLatestVersion: function (name) {
var self = this;
return self._returnFirst("getLatestVersion", arguments, ACCEPT_NON_EMPTY);
@@ -147,14 +141,6 @@ _.extend(LayeredCatalog.prototype, {
return self.otherCatalog[f].apply(self.otherCatalog, splittedArgs);
},
getLocalPackageNames: function () {
return this.localCatalog.getAllPackageNames();
},
getPackageSource: function (packageName) {
return this.localCatalog.getPackageSource(packageName);
},
getPackage: function (name) {
return this._returnFirst("getPackage", arguments, ACCEPT_NON_EMPTY);
},
@@ -180,14 +166,6 @@ _.extend(LayeredCatalog.prototype, {
return result;
},
initialize: function (options) {
this.localCatalog.initialize(options);
},
reset: function () {
this.localCatalog.reset();
},
// As getVersion, but returns info on the latest version of the
// package, or null if the package doesn't exist or has no versions.
// It does not include prereleases (with dashes in the version);

View File

@@ -11,13 +11,13 @@ var utils = require('./utils.js');
// .meteor/packages file on disk.)
//
// It has a corresponding JSON format (used, eg, inside buildinfo files).
exports.PackageMap = function (versions, cat) {
exports.PackageMap = function (versions, localCatalog) {
var self = this;
self._map = {};
self.catalog = cat;
self._localCatalog = localCatalog;
_.each(versions, function (version, packageName) {
var packageSource = cat.getPackageSource(packageName);
var packageSource = localCatalog.getPackageSource(packageName);
if (packageSource) {
self._map[packageName] =
{ kind: 'local', version: version, packageSource: packageSource };
@@ -50,7 +50,7 @@ _.extend(exports.PackageMap.prototype, {
throw Error("not a subset: " + packageName);
subsetVersions[packageName] = info.version;
});
return new exports.PackageMap(subsetVersions, self.catalog);
return new exports.PackageMap(subsetVersions, self._localCatalog);
},
toJSON: function () {

View File

@@ -401,7 +401,7 @@ _.extend(exports.ProjectContext.prototype, {
return; // error is already in buildmessage
self.packageMap = new packageMapModule.PackageMap(
solution.answer, self.projectCatalog);
solution.answer, self.localCatalog);
self.packageMapDelta = new packageMapModule.PackageMapDelta({
cachedVersions: cachedVersions,
@@ -444,15 +444,13 @@ _.extend(exports.ProjectContext.prototype, {
var self = this;
buildmessage.assertInCapture();
self.projectCatalog = new catalog.LayeredCatalog;
self.localCatalog = new catalogLocal.LocalCatalog({
containingCatalog: self.projectCatalog
});
self.projectCatalog.setCatalogs(self.localCatalog, catalog.official);
self.localCatalog = new catalogLocal.LocalCatalog;
self.projectCatalog = new catalog.LayeredCatalog(
self.localCatalog, catalog.official);
var searchDirs = self._localPackageSearchDirs();
buildmessage.enterJob({ title: "scanning local packages" }, function () {
self.projectCatalog.initialize({
self.localCatalog.initialize({
localPackageSearchDirs: searchDirs,
explicitlyAddedLocalPackageDirs: self._explicitlyAddedLocalPackageDirs
});