mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
fix bug in 'meteor add x@=1.0.0'
Used to print a "avoid conflicting dependencies" message. Now doesn't. Start moving some uses of splitConstraint to parseConstraint
This commit is contained in:
@@ -132,7 +132,11 @@ ConstraintSolver.PackagesResolver.prototype.resolve = function (
|
||||
});
|
||||
|
||||
check(dependencies, [String]);
|
||||
check(constraints, [{ packageName: String, version: String, type: String }]);
|
||||
|
||||
check(constraints, [{
|
||||
packageName: String, version: String, type: String,
|
||||
constraintString: Match.Optional(Match.OneOf(String, null))
|
||||
}]);
|
||||
check(options, {
|
||||
_testing: Match.Optional(Boolean),
|
||||
breaking: Match.Optional(Boolean),
|
||||
|
||||
@@ -13,7 +13,8 @@ PackageVersion = {};
|
||||
// 3. "at-least" - A@>=x.y.z - constraints package A to version x.y.z or higher.
|
||||
// "pick A at least at x.y.z"
|
||||
PackageVersion.parseVersionConstraint = function (versionString) {
|
||||
var versionDesc = { version: null, type: "compatible-with" };
|
||||
var versionDesc = { version: null, type: "compatible-with",
|
||||
constraintString: versionString };
|
||||
|
||||
// XXX #noconstraint #geoff #changed
|
||||
// XXX remove none when it is no longer used
|
||||
@@ -47,7 +48,8 @@ PackageVersion.parseConstraint = function (constraintString) {
|
||||
|
||||
var splitted = constraintString.split('@');
|
||||
|
||||
var constraint = { name: "", version: null, type: "compatible-with" };
|
||||
var constraint = { name: "", version: null,
|
||||
type: "compatible-with", constraintString: null };
|
||||
var name = splitted[0];
|
||||
var versionString = splitted[1];
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ Npm.depends({
|
||||
|
||||
Package.on_use(function (api) {
|
||||
api.export('PackageVersion');
|
||||
api.use('underscore');
|
||||
api.add_files([ 'package-version-parser.js' ], ['server']);
|
||||
});
|
||||
|
||||
|
||||
@@ -1250,60 +1250,60 @@ main.registerCommand({
|
||||
// we don't specify these constraints until we get them back from the
|
||||
// constraint solver.
|
||||
var constraints = _.map(options.args, function (packageReq) {
|
||||
return utils.splitConstraint(packageReq);
|
||||
return utils.parseConstraint(packageReq);
|
||||
});
|
||||
_.each(constraints, function (constraint) {
|
||||
// Check that the package exists.
|
||||
if (! catalog.complete.getPackage(constraint.package)) {
|
||||
process.stderr.write(constraint.package + ": no such package\n");
|
||||
if (! catalog.complete.getPackage(constraint.name)) {
|
||||
process.stderr.write(constraint.name + ": no such package\n");
|
||||
failed = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// If the version was specified, check that the version exists.
|
||||
if ( constraint.constraint !== null) {
|
||||
var version = _.clone(constraint.constraint);
|
||||
if (version[0] === '=')
|
||||
version = version.split('=')[1];
|
||||
if (constraint.version !== null) {
|
||||
var versionInfo = catalog.complete.getVersion(
|
||||
constraint.package,
|
||||
version);
|
||||
constraint.name,
|
||||
constraint.version);
|
||||
if (! versionInfo) {
|
||||
process.stderr.write(
|
||||
constraint.package + "@" + version + ": no such version\n");
|
||||
constraint.name + "@" + constraint.version + ": no such version\n");
|
||||
failed = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Check that the constraint is new. If we are already using the package at
|
||||
// the same constraint in the app, return from this function.
|
||||
if (_.has(packages, constraint.package)) {
|
||||
if (packages[constraint.package] === constraint.constraint) {
|
||||
process.stderr.write(constraint.package + " with version constraint " +
|
||||
constraint.constraint + " has already been added.\n");
|
||||
failed = true;
|
||||
if (_.has(packages, constraint.name)) {
|
||||
if (packages[constraint.name] === constraint.constraintString) {
|
||||
process.stderr.write(
|
||||
constraint.name + " with version constraint " +
|
||||
constraint.constraintString + " has already been added.\n");
|
||||
failed = true;
|
||||
} else {
|
||||
if (packages[constraint.package]) {
|
||||
process.stdout.write("Currently using "+ constraint.package +
|
||||
" with version constraint " + packages[constraint.package]
|
||||
+"\n");
|
||||
if (packages[constraint.name]) {
|
||||
process.stdout.write(
|
||||
"Currently using " + constraint.name +
|
||||
" with version constraint " + packages[constraint.name]
|
||||
+"\n");
|
||||
} else {
|
||||
process.stdout.write("Currently using "+ constraint.package +
|
||||
process.stdout.write("Currently using "+ constraint.name +
|
||||
" without any version constraint\n");
|
||||
}
|
||||
process.stdout.write("Constraint will be changed to " +
|
||||
constraint.constraint + "\n");
|
||||
constraint.constraintString + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Add the package to our direct dependency constraints that we get
|
||||
// from .meteor/packages.
|
||||
packages[constraint.package] = constraint.constraint;
|
||||
packages[constraint.name] = constraint.constraintString;
|
||||
|
||||
// Also, add it to all of our combined dependencies.
|
||||
allPackages.push(
|
||||
_.extend({ packageName: constraint.package },
|
||||
utils.parseVersionConstraint(constraint.constraint)));
|
||||
var constraintForResolver = _.clone(constraint);
|
||||
constraintForResolver.packageName = constraintForResolver.name;
|
||||
delete constraintForResolver.name;
|
||||
allPackages.push(constraintForResolver);
|
||||
});
|
||||
|
||||
// If the user asked for invalid packages, then the user probably expects a
|
||||
@@ -1344,21 +1344,21 @@ main.registerCommand({
|
||||
var downloaded = project.addPackages(constraints, newVersions);
|
||||
|
||||
var ret = project.showPackageChanges(versions, newVersions, {
|
||||
skipPackages: constraints,
|
||||
skipPackages: _.pluck(constraints, 'name'),
|
||||
ondiskPackages: downloaded});
|
||||
if (ret !== 0) return ret;
|
||||
|
||||
// Show the user the messageLog of the packages that they installed.
|
||||
process.stdout.write("Successfully added the following packages.\n");
|
||||
_.each(constraints, function (constraint) {
|
||||
var version = newVersions[constraint.package];
|
||||
var versionRecord = catalog.complete.getVersion(constraint.package, version);
|
||||
if (constraint.constraint !== null &&
|
||||
version !== constraint.constraint) {
|
||||
process.stdout.write("Added " + constraint.package + " at version " + version +
|
||||
var version = newVersions[constraint.name];
|
||||
var versionRecord = catalog.complete.getVersion(constraint.name, version);
|
||||
if (constraint.constraintString !== null &&
|
||||
version !== constraint.version) {
|
||||
process.stdout.write("Added " + constraint.name + " at version " + version +
|
||||
" to avoid conflicting dependencies.\n");
|
||||
}
|
||||
process.stdout.write(constraint.package +
|
||||
process.stdout.write(constraint.name +
|
||||
(versionRecord.description ?
|
||||
(": " + versionRecord.description) :
|
||||
"") + "\n");
|
||||
|
||||
@@ -693,12 +693,14 @@ _.extend(Project.prototype, {
|
||||
}
|
||||
|
||||
// We can continue normally, so set our own internal variables.
|
||||
self.constraints = _.extend(self.constraints, moreDeps);
|
||||
_.each(moreDeps, function (constraint) {
|
||||
self.constraints[constraint.name] = constraint.constraintString;
|
||||
});
|
||||
self.dependencies = newVersions;
|
||||
|
||||
// Remove the old constraints on the same constraints, since we are going to
|
||||
// overwrite them.
|
||||
self._removePackageRecords(_.pluck(moreDeps, 'package'));
|
||||
self._removePackageRecords(_.pluck(moreDeps, 'name'));
|
||||
|
||||
// Add to the packages file. Do this first, since the versions file is
|
||||
// derived from this one and can always be reconstructed later. We read the
|
||||
@@ -706,10 +708,10 @@ _.extend(Project.prototype, {
|
||||
var packages = self._getConstraintFile();
|
||||
var lines = files.getLinesOrEmpty(packages);
|
||||
_.each(moreDeps, function (constraint) {
|
||||
if (constraint.constraint) {
|
||||
lines.push(constraint.package + '@' + constraint.constraint);
|
||||
if (constraint.constraintString) {
|
||||
lines.push(constraint.name + '@' + constraint.constraintString);
|
||||
} else {
|
||||
lines.push(constraint.package);
|
||||
lines.push(constraint.name);
|
||||
}
|
||||
});
|
||||
lines.push('\n');
|
||||
|
||||
Reference in New Issue
Block a user