Exclude published package from previousSolution

When you `meteor publish` a package (not from an app), a
ProjectContext is created that gets the Version Solver
"previousSolution" from the .versions file in the project directory.
From the point of view of the Version Solver, the package itself is
a root dependency, so if the version changes from last time, you
may be asked to pass --allow-incompatible-update!  That isn't right.
However, the ProjectContext created by `meteor publish` doesn't know
it is created for a particular package.  But it does have the package
marked as "explicitly added."  So for now, the simplest thing to do
is to alter the input to the Version Solver based on the value of
explicitlyAddedLocalPackageDirs.

Oh, another wrinkle here is that we don't actually know the name of
the package we're publishing when we create the PackageContext, so it
can't be an option.

Example of a failing self-test that now passes:
'packages with organizations'
This commit is contained in:
David Greenspan
2015-03-30 16:58:21 -07:00
parent 56e1e08292
commit 4a4680b5d2

View File

@@ -168,6 +168,16 @@ _.extend(ProjectContext.prototype, {
// Initialized by initializeCatalog.
self.projectCatalog = null;
self.localCatalog = null;
// Once the catalog is read and the names of the "explicitly
// added" packages are determined, they will be listed here.
// (See explicitlyAddedLocalPackageDirs.)
// "Explicitly added" packages are typically present in non-app
// projects, like the one created by `meteor publish`. This list
// is used to avoid pinning such packages to their previous
// versions when we run the version solver, which prevents an
// error telling you to pass `--allow-incompatible-update` when
// you publish your package after bumping the major version.
self.explicitlyAddedPackageNames = null;
// Initialized by _resolveConstraints.
self.packageMap = null;
@@ -408,6 +418,13 @@ _.extend(ProjectContext.prototype, {
var anticipatedPrereleases = self._getAnticipatedPrereleases(
depsAndConstraints.constraints, cachedVersions);
if (self.explicitlyAddedPackageNames.length) {
cachedVersions = _.clone(cachedVersions);
_.each(self.explicitlyAddedPackageNames, function (p) {
delete cachedVersions[p];
});
}
var resolverRunCount = 0;
// Nothing before this point looked in the official or project catalog!
@@ -531,6 +548,15 @@ _.extend(ProjectContext.prototype, {
return;
}
self.explicitlyAddedPackageNames = [];
_.each(self._explicitlyAddedLocalPackageDirs, function (dir) {
var localVersionRecord =
self.localCatalog.getVersionBySourceRoot(dir);
if (localVersionRecord) {
self.explicitlyAddedPackageNames.push(localVersionRecord.packageName);
}
});
self._completedStage = STAGE.INITIALIZE_CATALOG;
}
);
@@ -688,6 +714,7 @@ _.extend(ProjectContext.prototype, {
(release.current.isCheckout() && self.releaseFile.isCheckout()) ||
(! release.current.isCheckout() &&
release.current.name === self.releaseFile.fullReleaseName))) {
self.packageMapFile.write(self.packageMap);
}