mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
support multiple major versions in meteor 0.9.3 and above. A little hacky in the tool around keeping old interfaces, but it works
This commit is contained in:
@@ -202,6 +202,58 @@ Tinytest.add("constraint solver - no results", function (test) {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Tinytest.add("constraint solver - any-of constraint", function (test) {
|
||||
var resolver = makeResolver([
|
||||
["one-of", "1.0.0", {indirect: "1.0.0 || 2.0.0"}],
|
||||
["important", "1.0.0", {indirect: "2.0.0"}],
|
||||
["indirect", "1.0.0"],
|
||||
["indirect", "2.0.0"]
|
||||
]);
|
||||
|
||||
testWithResolver(test, resolver, function (t, FAIL) {
|
||||
t({ "one-of": "=1.0.0", "important": "1.0.0" }, {
|
||||
"one-of": "1.0.0",
|
||||
"important": "1.0.0",
|
||||
"indirect": "2.0.0"
|
||||
}, { _testing: true });
|
||||
});
|
||||
|
||||
resolver = makeResolver([
|
||||
["one-of", "1.0.0", {indirect: "1.0.0 || 2.0.0"}],
|
||||
["one-of-equal", "1.0.0", {indirect: "1.0.0 || =2.0.1"}],
|
||||
["important", "1.0.0", {indirect: "1.0.0"}],
|
||||
["indirect", "1.0.0"],
|
||||
["indirect", "2.0.0"],
|
||||
["indirect", "2.0.1"]
|
||||
]);
|
||||
|
||||
testWithResolver(test, resolver, function (t, FAIL) {
|
||||
t({ "one-of": "=1.0.0", "important": "1.0.0" }, {
|
||||
"one-of": "1.0.0",
|
||||
"important": "1.0.0",
|
||||
"indirect": "1.0.0"
|
||||
}, { _testing: true });
|
||||
|
||||
t({ "one-of-equal": "1.0.0", "indirect": "2.0.0" }, {
|
||||
"one-of-equal": "1.0.0",
|
||||
"indirect": "2.0.1"
|
||||
}, { _testing: true });
|
||||
|
||||
t({ "one-of-equal": "1.0.0", "one-of": "1.0.0" }, {
|
||||
"one-of-equal": "1.0.0",
|
||||
"one-of": "1.0.0",
|
||||
"indirect": "1.0.0"
|
||||
}, { _testing: true });
|
||||
|
||||
FAIL({"one-of-equal": "1.0.0",
|
||||
"one-of": "1.0.0",
|
||||
"indirect" : "=2.0.0"},
|
||||
/constraints on indirect[^]+top level[^]+one-of-equal@1.0.0/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Tinytest.add("constraint solver - previousSolution", function (test) {
|
||||
testWithResolver(test, defaultResolver, function (t, FAIL) {
|
||||
// This is what you get if you lock sparky-forms to 1.0.0.
|
||||
@@ -252,6 +304,7 @@ Tinytest.add("constraint solver - previousSolution", function (test) {
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Tinytest.add("constraint solver - no constraint dependency - anything", function (test) {
|
||||
var versions = defaultResolver.resolve(["sparkle"], [], { _testing: true }).answer;
|
||||
test.isTrue(_.isString(versions.sparkle));
|
||||
|
||||
@@ -161,9 +161,10 @@ ConstraintSolver.PackagesResolver.prototype.resolve = function (
|
||||
|
||||
check(constraints, [{
|
||||
packageName: String,
|
||||
version: Match.OneOf(String, null),
|
||||
type: String,
|
||||
constraintString: Match.Optional(Match.OneOf(String, null))
|
||||
name: Match.Optional(String),
|
||||
constraints: [{
|
||||
version: Match.OneOf(String, null),
|
||||
type: String }]
|
||||
}]);
|
||||
|
||||
check(options, {
|
||||
@@ -302,7 +303,13 @@ ConstraintSolver.PackagesResolver.prototype._splitDepsToConstraints =
|
||||
});
|
||||
|
||||
_.each(inputConstraints, function (constraint) {
|
||||
var constraintStr = PackageVersion.constraintToVersionString(constraint);
|
||||
var constraintStr = constraint.constraintString;
|
||||
if (!constraintStr) {
|
||||
constraintStr = constraint.version ?
|
||||
constraint.version : "";
|
||||
if (constraint.type === "exactly")
|
||||
constraintStr = "=" + constraintStr;
|
||||
}
|
||||
_.each(self._unibuildsForPackage(constraint.packageName), function (unibuildName) {
|
||||
constraints.push(self.resolver.getConstraint(unibuildName, constraintStr));
|
||||
});
|
||||
|
||||
@@ -13,16 +13,16 @@ Tinytest.add("constraint solver - resolver, get exact deps", function (test) {
|
||||
// \ \-> D => E
|
||||
// \-> \-> F
|
||||
var resolver = new ConstraintSolver.Resolver();
|
||||
var A100 = new ConstraintSolver.UnitVersion("A", "1.0.0", "1.0.0");
|
||||
var B100 = new ConstraintSolver.UnitVersion("B", "1.0.0", "1.0.0");
|
||||
var C100 = new ConstraintSolver.UnitVersion("C", "1.0.0", "1.0.0");
|
||||
var D110 = new ConstraintSolver.UnitVersion("D", "1.1.0", "1.0.0");
|
||||
var E100 = new ConstraintSolver.UnitVersion("E", "1.0.0", "1.0.0");
|
||||
var F120 = new ConstraintSolver.UnitVersion("F", "1.2.0", "1.0.0");
|
||||
var A100 = new ConstraintSolver.UnitVersion("a", "1.0.0", "1.0.0");
|
||||
var B100 = new ConstraintSolver.UnitVersion("b", "1.0.0", "1.0.0");
|
||||
var C100 = new ConstraintSolver.UnitVersion("c", "1.0.0", "1.0.0");
|
||||
var D110 = new ConstraintSolver.UnitVersion("d", "1.1.0", "1.0.0");
|
||||
var E100 = new ConstraintSolver.UnitVersion("e", "1.0.0", "1.0.0");
|
||||
var F120 = new ConstraintSolver.UnitVersion("f", "1.2.0", "1.0.0");
|
||||
// Ensure that the resolver knows that these versions exist and have ECV =
|
||||
// 1.0.0.
|
||||
var F100 = new ConstraintSolver.UnitVersion("F", "1.0.0", "1.0.0");
|
||||
var F110 = new ConstraintSolver.UnitVersion("F", "1.1.0", "1.0.0");
|
||||
var F100 = new ConstraintSolver.UnitVersion("f", "1.0.0", "1.0.0");
|
||||
var F110 = new ConstraintSolver.UnitVersion("f", "1.1.0", "1.0.0");
|
||||
|
||||
resolver.addUnitVersion(A100);
|
||||
resolver.addUnitVersion(B100);
|
||||
@@ -33,24 +33,24 @@ Tinytest.add("constraint solver - resolver, get exact deps", function (test) {
|
||||
resolver.addUnitVersion(F110);
|
||||
resolver.addUnitVersion(F120);
|
||||
|
||||
A100.addDependency("B");
|
||||
A100.addConstraint(resolver.getConstraint("B", "=1.0.0"));
|
||||
B100.addDependency("C");
|
||||
B100.addConstraint(resolver.getConstraint("C", "=1.0.0"));
|
||||
A100.addDependency("b");
|
||||
A100.addConstraint(resolver.getConstraint("b", "=1.0.0"));
|
||||
B100.addDependency("c");
|
||||
B100.addConstraint(resolver.getConstraint("c", "=1.0.0"));
|
||||
// a dependency w/o a constraint, still should pick it
|
||||
B100.addDependency("D");
|
||||
D110.addDependency("E");
|
||||
D110.addConstraint(resolver.getConstraint("E", "=1.0.0"));
|
||||
B100.addDependency("F");
|
||||
B100.addDependency("d");
|
||||
D110.addDependency("e");
|
||||
D110.addConstraint(resolver.getConstraint("e", "=1.0.0"));
|
||||
B100.addDependency("f");
|
||||
// a non-exact constraint
|
||||
B100.addConstraint(resolver.getConstraint("F", "1.0.0"));
|
||||
A100.addDependency("F");
|
||||
A100.addConstraint(resolver.getConstraint("F", "1.1.0"));
|
||||
B100.addConstraint(resolver.getConstraint("f", "1.0.0"));
|
||||
A100.addDependency("f");
|
||||
A100.addConstraint(resolver.getConstraint("f", "1.1.0"));
|
||||
|
||||
var solution = resolver.resolve(["A"], [], {
|
||||
var solution = resolver.resolve(["a"], [], {
|
||||
// Prefer later F when possible.
|
||||
costFunction: function (state) {
|
||||
var F = mori.get(state.choices, "F");
|
||||
var F = mori.get(state.choices, "f");
|
||||
var distanceF = F ? semver2number(F.version) : 0;
|
||||
return -distanceF;
|
||||
}
|
||||
@@ -61,12 +61,12 @@ Tinytest.add("constraint solver - resolver, get exact deps", function (test) {
|
||||
|
||||
Tinytest.add("constraint solver - resolver, cost function - pick latest", function (test) {
|
||||
var resolver = new ConstraintSolver.Resolver();
|
||||
var A100 = new ConstraintSolver.UnitVersion("A", "1.0.0", "1.0.0");
|
||||
var A110 = new ConstraintSolver.UnitVersion("A", "1.1.0", "1.0.0");
|
||||
var B100 = new ConstraintSolver.UnitVersion("B", "1.0.0", "1.0.0");
|
||||
var C100 = new ConstraintSolver.UnitVersion("C", "1.0.0", "1.0.0");
|
||||
var C110 = new ConstraintSolver.UnitVersion("C", "1.1.0", "1.0.0");
|
||||
var C120 = new ConstraintSolver.UnitVersion("C", "1.2.0", "1.0.0");
|
||||
var A100 = new ConstraintSolver.UnitVersion("a", "1.0.0", "1.0.0");
|
||||
var A110 = new ConstraintSolver.UnitVersion("a", "1.1.0", "1.0.0");
|
||||
var B100 = new ConstraintSolver.UnitVersion("b", "1.0.0", "1.0.0");
|
||||
var C100 = new ConstraintSolver.UnitVersion("c", "1.0.0", "1.0.0");
|
||||
var C110 = new ConstraintSolver.UnitVersion("c", "1.1.0", "1.0.0");
|
||||
var C120 = new ConstraintSolver.UnitVersion("c", "1.2.0", "1.0.0");
|
||||
|
||||
resolver.addUnitVersion(A100);
|
||||
resolver.addUnitVersion(A110);
|
||||
@@ -75,17 +75,17 @@ Tinytest.add("constraint solver - resolver, cost function - pick latest", functi
|
||||
resolver.addUnitVersion(C110);
|
||||
resolver.addUnitVersion(C120);
|
||||
|
||||
A100.addDependency("C");
|
||||
A110.addDependency("C");
|
||||
B100.addDependency("A");
|
||||
B100.addConstraint(resolver.getConstraint("A", "=1.0.0"));
|
||||
B100.addDependency("C");
|
||||
B100.addConstraint(resolver.getConstraint("C", "1.1.0"));
|
||||
A100.addDependency("c");
|
||||
A110.addDependency("c");
|
||||
B100.addDependency("a");
|
||||
B100.addConstraint(resolver.getConstraint("a", "=1.0.0"));
|
||||
B100.addDependency("c");
|
||||
B100.addConstraint(resolver.getConstraint("c", "1.1.0"));
|
||||
|
||||
// Run looking for a conservative solution for A
|
||||
var AOnlySolution = resolver.resolve(["A"], [], {
|
||||
var AOnlySolution = resolver.resolve(["a"], [], {
|
||||
costFunction: function (state) {
|
||||
var A = mori.get(state.choices, "A");
|
||||
var A = mori.get(state.choices, "a");
|
||||
var distanceA = A ? semver2number(A.version) : 0;
|
||||
return distanceA - 100;
|
||||
}
|
||||
@@ -93,10 +93,10 @@ Tinytest.add("constraint solver - resolver, cost function - pick latest", functi
|
||||
|
||||
resultEquals(test, AOnlySolution, [A100, C100]);
|
||||
|
||||
var AnBSolution = resolver.resolve(["A", "B"], [], {
|
||||
var AnBSolution = resolver.resolve(["a", "b"], [], {
|
||||
costFunction: function (state) {
|
||||
var C = mori.get(state.choices, "C");
|
||||
var A = mori.get(state.choices, "A");
|
||||
var C = mori.get(state.choices, "c");
|
||||
var A = mori.get(state.choices, "a");
|
||||
var distanceC = C ? semver2number(C.version) : 0;
|
||||
var distanceA = A ? semver2number(A.version) : 0;
|
||||
return 1000000000 - distanceC - distanceA;
|
||||
@@ -108,11 +108,11 @@ Tinytest.add("constraint solver - resolver, cost function - pick latest", functi
|
||||
|
||||
Tinytest.add("constraint solver - resolver, cost function - avoid upgrades", function (test) {
|
||||
var resolver = new ConstraintSolver.Resolver();
|
||||
var A100 = new ConstraintSolver.UnitVersion("A", "1.0.0", "1.0.0");
|
||||
var A110 = new ConstraintSolver.UnitVersion("A", "1.1.0", "1.0.0");
|
||||
var B100 = new ConstraintSolver.UnitVersion("B", "1.0.0", "1.0.0");
|
||||
var B110 = new ConstraintSolver.UnitVersion("B", "1.1.0", "1.0.0");
|
||||
var C100 = new ConstraintSolver.UnitVersion("C", "1.0.0", "1.0.0");
|
||||
var A100 = new ConstraintSolver.UnitVersion("a", "1.0.0", "1.0.0");
|
||||
var A110 = new ConstraintSolver.UnitVersion("a", "1.1.0", "1.0.0");
|
||||
var B100 = new ConstraintSolver.UnitVersion("b", "1.0.0", "1.0.0");
|
||||
var B110 = new ConstraintSolver.UnitVersion("b", "1.1.0", "1.0.0");
|
||||
var C100 = new ConstraintSolver.UnitVersion("c", "1.0.0", "1.0.0");
|
||||
|
||||
resolver.addUnitVersion(A100);
|
||||
resolver.addUnitVersion(A110);
|
||||
@@ -120,17 +120,17 @@ Tinytest.add("constraint solver - resolver, cost function - avoid upgrades", fun
|
||||
resolver.addUnitVersion(B110);
|
||||
resolver.addUnitVersion(C100);
|
||||
|
||||
A100.addDependency("B");
|
||||
A100.addConstraint(resolver.getConstraint("B", "1.1.0"));
|
||||
A110.addDependency("C");
|
||||
A110.addConstraint(resolver.getConstraint("C", "1.0.0"));
|
||||
A100.addDependency("b");
|
||||
A100.addConstraint(resolver.getConstraint("b", "1.1.0"));
|
||||
A110.addDependency("c");
|
||||
A110.addConstraint(resolver.getConstraint("c", "1.0.0"));
|
||||
|
||||
// We had one dependency on B and the previous run of resolver told us to us
|
||||
// B@1.0.0. Now we are adding the package A in a conservative manner. The
|
||||
// constraint solver should keep B from upgrading by picking a newer version
|
||||
// of A that uses C.
|
||||
var lockedVersions = [B100];
|
||||
var solution = resolver.resolve(["A", "B"], [], {
|
||||
var solution = resolver.resolve(["a", "b"], [], {
|
||||
costFunction: function (state) {
|
||||
return mori.reduce(mori.sum, 0, mori.map(function (nameAndUv) {
|
||||
var name = mori.first(nameAndUv);
|
||||
@@ -148,13 +148,13 @@ Tinytest.add("constraint solver - resolver, cost function - avoid upgrades", fun
|
||||
|
||||
Tinytest.add("constraint solver - resolver, don't pick rcs", function (test) {
|
||||
var resolver = new ConstraintSolver.Resolver();
|
||||
var A100 = new ConstraintSolver.UnitVersion("A", "1.0.0", "1.0.0");
|
||||
var A100rc1 = new ConstraintSolver.UnitVersion("A", "1.0.0-rc1", "1.0.0");
|
||||
var A100 = new ConstraintSolver.UnitVersion("a", "1.0.0", "1.0.0");
|
||||
var A100rc1 = new ConstraintSolver.UnitVersion("a", "1.0.0-rc1", "1.0.0");
|
||||
|
||||
resolver.addUnitVersion(A100rc1);
|
||||
resolver.addUnitVersion(A100);
|
||||
var basicConstraint = resolver.getConstraint("A", "");
|
||||
var rcConstraint = resolver.getConstraint("A", "1.0.0-rc1");
|
||||
var basicConstraint = resolver.getConstraint("a", "");
|
||||
var rcConstraint = resolver.getConstraint("a", "1.0.0-rc1");
|
||||
|
||||
// Make the non-rc one more costly. But we still shouldn't choose it unless it
|
||||
// was specified in an initial constraint!
|
||||
@@ -170,15 +170,14 @@ Tinytest.add("constraint solver - resolver, don't pick rcs", function (test) {
|
||||
};
|
||||
|
||||
var solution = resolver.resolve(
|
||||
["A"], [basicConstraint], {costFunction: proRcCostFunction });
|
||||
["a"], [basicConstraint], {costFunction: proRcCostFunction });
|
||||
resultEquals(test, solution, [A100]);
|
||||
|
||||
solution = resolver.resolve(
|
||||
["A"], [rcConstraint], {costFunction: proRcCostFunction });
|
||||
["a"], [rcConstraint], {costFunction: proRcCostFunction });
|
||||
resultEquals(test, solution, [A100rc1]);
|
||||
});
|
||||
|
||||
function semver2number (semverStr) {
|
||||
return parseInt(semverStr.replace(/\./g, ""));
|
||||
}
|
||||
|
||||
|
||||
@@ -359,27 +359,24 @@ _.extend(ConstraintSolver.UnitVersion.prototype, {
|
||||
// new PackageVersion.Constraint("pacakgeA@=2.1.0")
|
||||
ConstraintSolver.Constraint = function (name, versionString) {
|
||||
var self = this;
|
||||
|
||||
if (versionString !== undefined) {
|
||||
_.extend(self,
|
||||
PackageVersion.parseVersionConstraint(versionString));
|
||||
self.name = name;
|
||||
} else {
|
||||
// borrows the structure from the parseVersionConstraint format:
|
||||
// - type - String [compatible-with|exactly|any-reasonable]
|
||||
// - version - String - meteor version string
|
||||
_.extend(self, PackageVersion.parseConstraint(name));
|
||||
if (versionString) {
|
||||
name = name + "@" + versionString;
|
||||
}
|
||||
// See comment in UnitVersion constructor.
|
||||
if (self.version)
|
||||
self.version = self.version.replace(/\+.*$/, '');
|
||||
|
||||
// See comment in UnitVersion constructor. We want to strip out build IDs
|
||||
// because the code they represent is considered equivalent.
|
||||
_.extend(self, PackageVersion.parseConstraint(name, {
|
||||
removeBuildIDs: true,
|
||||
archesOK: true
|
||||
}));
|
||||
|
||||
};
|
||||
|
||||
ConstraintSolver.Constraint.prototype.toString = function (options) {
|
||||
var self = this;
|
||||
options = options || {};
|
||||
var name = options.removeUnibuild ? removeUnibuild(self.name) : self.name;
|
||||
return name + "@" + PackageVersion.constraintToVersionString(self);
|
||||
return name + "@" + self.constraintString;
|
||||
};
|
||||
|
||||
|
||||
@@ -393,69 +390,73 @@ ConstraintSolver.Constraint.prototype.isSatisfied = function (
|
||||
candidateUV.name);
|
||||
}
|
||||
|
||||
if (self.type === "any-reasonable") {
|
||||
// Non-prerelease versions are always reasonable, and if we are OK with
|
||||
// using RCs all the time, then they are reasonable too.
|
||||
if (!/-/.test(candidateUV.version) ||
|
||||
resolveContext.useRCsOK)
|
||||
return true;
|
||||
return _.some(self.constraints, function (currConstraint) {
|
||||
if (currConstraint.type === "any-reasonable") {
|
||||
// Non-prerelease versions are always reasonable, and if we are OK with
|
||||
// using RCs all the time, then they are reasonable too.
|
||||
if (!/-/.test(candidateUV.version) ||
|
||||
resolveContext.useRCsOK)
|
||||
return true;
|
||||
|
||||
// Is it a pre-release version that was explicitly mentioned at the top
|
||||
// level?
|
||||
if (_.has(resolveContext.topLevelPrereleases, self.name) &&
|
||||
_.has(resolveContext.topLevelPrereleases[self.name],
|
||||
candidateUV.version)) {
|
||||
return true;
|
||||
}
|
||||
// Is it a pre-release version that was explicitly mentioned at the top
|
||||
// level?
|
||||
if (_.has(resolveContext.topLevelPrereleases, self.name) &&
|
||||
_.has(resolveContext.topLevelPrereleases[self.name],
|
||||
candidateUV.version)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Otherwise, not this pre-release!
|
||||
return false;
|
||||
}
|
||||
|
||||
if (self.type === "exactly") {
|
||||
return self.version === candidateUV.version;
|
||||
}
|
||||
|
||||
if (self.type !== "compatible-with") {
|
||||
throw Error("Unknown constraint type: " + self.type);
|
||||
}
|
||||
|
||||
// If you are asking for a pre-release, you need to get exactly that one.
|
||||
// (@1.2.3-rc1 does not match 1.2.4.)
|
||||
if (/-/.test(self.version)) {
|
||||
return self.version === candidateUV.version;
|
||||
}
|
||||
|
||||
// If you're not asking for a pre-release (and you are not in pre-releases-OK
|
||||
// mode), you'll only get it if it was a top level explicit mention (eg, in
|
||||
// the release).
|
||||
if (/-/.test(candidateUV.version) && !resolveContext.useRCsOK) {
|
||||
if (self.version === candidateUV.version)
|
||||
return true;
|
||||
if (!_.has(resolveContext.topLevelPrereleases, self.name) ||
|
||||
!_.has(resolveContext.topLevelPrereleases[self.name],
|
||||
candidateUV.version)) {
|
||||
// Otherwise, not this pre-release!
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// If the candidate version is less than the version named in the constraint,
|
||||
// we are not satisfied.
|
||||
if (PackageVersion.lessThan(candidateUV.version, self.version))
|
||||
return false;
|
||||
if (currConstraint.type === "exactly") {
|
||||
return currConstraint.version === candidateUV.version;
|
||||
}
|
||||
|
||||
var myECV = resolver.getEarliestCompatibleVersion(self.name, self.version);
|
||||
// If the constraint is "@1.2.3" and 1.2.3 doesn't exist, then nothing can
|
||||
// match. This is because we don't know the ECV (compatibility class) of
|
||||
// 1.2.3!
|
||||
if (!myECV)
|
||||
return false;
|
||||
if (currConstraint.type !== "compatible-with") {
|
||||
throw Error("Unknown constraint type: " + currConstraint.type);
|
||||
}
|
||||
|
||||
// If you are asking for a pre-release, you need to get exactly that one.
|
||||
// (@1.2.3-rc1 does not match 1.2.4.)
|
||||
if (/-/.test(currConstraint.version)) {
|
||||
return currConstraint.version === candidateUV.version;
|
||||
}
|
||||
|
||||
// If you're not asking for a pre-release (and you are not in pre-releases-OK
|
||||
// mode), you'll only get it if it was a top level explicit mention (eg, in
|
||||
// the release).
|
||||
if (/-/.test(candidateUV.version) && !resolveContext.useRCsOK) {
|
||||
if (currConstraint.version === candidateUV.version)
|
||||
return true;
|
||||
if (!_.has(resolveContext.topLevelPrereleases, self.name) ||
|
||||
!_.has(resolveContext.topLevelPrereleases[self.name],
|
||||
candidateUV.version)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// If the candidate version is less than the version named in the constraint,
|
||||
// we are not satisfied.
|
||||
if (PackageVersion.lessThan(candidateUV.version, currConstraint.version))
|
||||
return false;
|
||||
|
||||
var myECV = resolver.getEarliestCompatibleVersion(
|
||||
self.name, currConstraint.version);
|
||||
// If the constraint is "@1.2.3" and 1.2.3 doesn't exist, then nothing can
|
||||
// match. This is because we don't know the ECV (compatibility class) of
|
||||
// 1.2.3!
|
||||
if (!myECV)
|
||||
return false;
|
||||
|
||||
// To be compatible, the two versions must have the same
|
||||
// earliestCompatibleVersion. If the earliestCompatibleVersions haven't been
|
||||
// overridden from their default, this means that the two versions have the
|
||||
// same major version number.
|
||||
return myECV === candidateUV.earliestCompatibleVersion;
|
||||
});
|
||||
|
||||
// To be compatible, the two versions must have the same
|
||||
// earliestCompatibleVersion. If the earliestCompatibleVersions haven't been
|
||||
// overridden from their default, this means that the two versions have the
|
||||
// same major version number.
|
||||
return myECV === candidateUV.earliestCompatibleVersion;
|
||||
};
|
||||
|
||||
// An object that records the general context of a resolve call. It can be
|
||||
|
||||
@@ -17,17 +17,22 @@ var FAIL = function (versionString) {
|
||||
Tinytest.add("Smart Package version string parsing - old format", function (test) {
|
||||
currentTest = test;
|
||||
|
||||
t("foo", { name: "foo", version: null, type: "any-reasonable" });
|
||||
t("foo-1234", { name: "foo-1234", version: null, type: "any-reasonable" });
|
||||
t("foo", { name: "foo", constraints: [{
|
||||
version: null, type: "any-reasonable" } ]});
|
||||
t("foo-1234", { name: "foo-1234", constraints: [{
|
||||
version: null, type: "any-reasonable" } ]});
|
||||
FAIL("my_awesome_InconsitentPackage123");
|
||||
});
|
||||
|
||||
Tinytest.add("Smart Package version string parsing - compatible version, compatible-with", function (test) {
|
||||
currentTest = test;
|
||||
|
||||
t("foo@1.2.3", { name: "foo", version: "1.2.3", type: "compatible-with" });
|
||||
t("foo-1233@1.2.3", { name: "foo-1233", version: "1.2.3", type: "compatible-with" });
|
||||
t("foo-bar@3.2.1", { name: "foo-bar", version: "3.2.1", type: "compatible-with" });
|
||||
t("foo@1.2.3", { name: "foo", constraints: [{
|
||||
version: "1.2.3", type: "compatible-with" } ]});
|
||||
t("foo-1233@1.2.3", { name: "foo-1233", constraints: [{
|
||||
version: "1.2.3", type: "compatible-with" } ]});
|
||||
t("foo-bar@3.2.1", { name: "foo-bar", constraints: [{
|
||||
version: "3.2.1", type: "compatible-with" } ]});
|
||||
FAIL("42@0.2.0");
|
||||
FAIL("foo@1.2.3.4");
|
||||
FAIL("foo@1.4");
|
||||
@@ -44,19 +49,27 @@ Tinytest.add("Smart Package version string parsing - compatible version, compati
|
||||
FAIL("foo-1233@1.2.3~");
|
||||
FAIL("foo-1233@1.2.3~0123");
|
||||
|
||||
t("foo@1.2.3~1", { name: "foo", version: "1.2.3~1", type: "compatible-with" });
|
||||
t("foo-bar@3.2.1-rc0~123", { name: "foo-bar", version: "3.2.1-rc0~123", type: "compatible-with" });
|
||||
t("foo-1233@1.2.3~5+1234", { name: "foo-1233", version: "1.2.3~5+1234", type: "compatible-with" });
|
||||
t("foo", { name: "foo", version: null, type: "any-reasonable" });
|
||||
t("foo@1.2.3~1", { name: "foo", constraints: [{
|
||||
version: "1.2.3~1", type: "compatible-with" } ]});
|
||||
t("foo-bar@3.2.1-rc0~123", { name: "foo-bar", constraints: [{
|
||||
version: "3.2.1-rc0~123", type: "compatible-with" } ]});
|
||||
t("foo-1233@1.2.3~5+1234", { name: "foo-1233", constraints: [{
|
||||
version: "1.2.3~5+1234", type: "compatible-with" } ]});
|
||||
t("foo", { name: "foo", constraints: [{
|
||||
version: null, type: "any-reasonable" } ]});
|
||||
});
|
||||
|
||||
Tinytest.add("Smart Package version string parsing - compatible version, exactly", function (test) {
|
||||
currentTest = test;
|
||||
|
||||
t("foo@=1.2.3", { name: "foo", version: "1.2.3", type: "exactly" });
|
||||
t("foo-bar@=3.2.1", { name: "foo-bar", version: "3.2.1", type: "exactly" });
|
||||
t("foo@=1.2.3~1", { name: "foo", version: "1.2.3~1", type: "exactly" });
|
||||
t("foo-bar@=3.2.1~34", { name: "foo-bar", version: "3.2.1~34", type: "exactly" });
|
||||
t("foo@=1.2.3", { name: "foo", constraints: [
|
||||
{ version: "1.2.3", type: "exactly" } ]});
|
||||
t("foo-bar@=3.2.1", { name: "foo-bar", constraints: [{
|
||||
version: "3.2.1", type: "exactly" } ]});
|
||||
t("foo@=1.2.3~1", { name: "foo", constraints: [{
|
||||
version: "1.2.3~1", type: "exactly" } ]});
|
||||
t("foo-bar@=3.2.1~34", { name: "foo-bar", constraints: [{
|
||||
version: "3.2.1~34", type: "exactly" } ]});
|
||||
|
||||
FAIL("42@=0.2.0");
|
||||
FAIL("foo@=1.2.3.4");
|
||||
@@ -83,6 +96,40 @@ Tinytest.add("Smart Package version string parsing - compatible version, exactly
|
||||
FAIL("foo@=>12.3.11");
|
||||
});
|
||||
|
||||
|
||||
Tinytest.add("Smart Package version string parsing - or", function (test) {
|
||||
currentTest = test;
|
||||
|
||||
t("foo@1.0.0 || 2.0.0 || 3.0.0 || =4.0.0-rc1",
|
||||
{ name: "foo", constraints:
|
||||
[{ version: "1.0.0", type: "compatible-with"},
|
||||
{ version: "2.0.0", type: "compatible-with"},
|
||||
{ version: "3.0.0", type: "compatible-with"},
|
||||
{ version: "4.0.0-rc1", type: "exactly"}]
|
||||
});
|
||||
t("foo-bar@=3.2.1 || 1.0.0",
|
||||
{ name: "foo-bar", constraints:
|
||||
[{ version: "3.2.1", type: "exactly"},
|
||||
{ version: "1.0.0", type: "compatible-with"}]
|
||||
});
|
||||
t("foo@=1.2.3~1 || 1.2.4",
|
||||
{ name: "foo", constraints:
|
||||
[{ version: "1.2.3~1", type: "exactly"},
|
||||
{ version: "1.2.4", type: "compatible-with"}]
|
||||
});
|
||||
t("foo-bar@=3.2.1~34 || =3.2.1-rc1",
|
||||
{ name: "foo-bar", constraints:
|
||||
[{ version: "3.2.1~34", type: "exactly"},
|
||||
{ version: "3.2.1-rc1", type: "exactly"}]
|
||||
});
|
||||
|
||||
FAIL("foo@1.0.0 1.0.0");
|
||||
FAIL("foo@1.0.0||1.0.0");
|
||||
FAIL("foo@1.0.0 | 1.0.0");
|
||||
FAIL("foo || bar");
|
||||
FAIL("foo@1.0.0-rc|1.0.0");
|
||||
});
|
||||
|
||||
Tinytest.add("Meteor Version string parsing - less than", function (test) {
|
||||
test.isTrue(PackageVersion.lessThan("1.0.0", "1.2.0"));
|
||||
test.isTrue(PackageVersion.lessThan("1.0.0~500", "1.2.0"));
|
||||
|
||||
@@ -465,7 +465,8 @@ _.extend(CompleteCatalog.prototype, {
|
||||
// Constraints for uniload should just be packages with no version
|
||||
// constraint and one local version (since they should all be in core).
|
||||
if (!_.has(constraint, 'packageName') ||
|
||||
constraint.type !== 'any-reasonable') {
|
||||
constraint.constraints.length > 1 ||
|
||||
constraint.constraints[0].type !== 'any-reasonable') {
|
||||
throw Error("Surprising constraint: " + JSON.stringify(constraint));
|
||||
}
|
||||
if (!_.has(self.versions, constraint.packageName)) {
|
||||
@@ -511,6 +512,10 @@ _.extend(CompleteCatalog.prototype, {
|
||||
deps.push(constraint.packageName);
|
||||
}
|
||||
delete constraint.weak;
|
||||
delete constraint.constraintString;
|
||||
if (_.has(constraint, "version")) {
|
||||
console.trace(constraint);
|
||||
}
|
||||
constr.push(constraint);
|
||||
});
|
||||
|
||||
@@ -525,15 +530,18 @@ _.extend(CompleteCatalog.prototype, {
|
||||
// for now: we can't use any packages that are of different versions from
|
||||
// what we've already decided from the project!
|
||||
_.each(project.project.getVersions(), function (version, name) {
|
||||
constr.push({packageName: name, version: version, type: 'exactly'});
|
||||
constr.push({packageName: name, constraints: [
|
||||
{ version: version, type: 'exactly'}] });
|
||||
});
|
||||
}
|
||||
|
||||
// Local packages can only be loaded from the version we have the source
|
||||
// for: that's a weak exact constraint.
|
||||
_.each(self.packageSources, function (packageSource, name) {
|
||||
constr.push({packageName: name, version: packageSource.version,
|
||||
type: 'exactly'});
|
||||
constr.push({packageName: name,
|
||||
constraints: [
|
||||
{ version: packageSource.version,
|
||||
type: 'exactly' }] });
|
||||
});
|
||||
|
||||
var patience = new utils.Patience({
|
||||
|
||||
@@ -1890,16 +1890,6 @@ main.registerCommand({
|
||||
return 1;
|
||||
}
|
||||
|
||||
// For every package name specified, add it to our list of package
|
||||
// constraints. Don't run the constraint solver until you have added all of
|
||||
// them -- add should be an atomic operation regardless of the package
|
||||
// order. Even though the package file should specify versions of its inputs,
|
||||
// we don't specify these constraints until we get them back from the
|
||||
// constraint solver.
|
||||
var constraints = _.map(args, function (packageReq) {
|
||||
return utils.parseConstraint(packageReq);
|
||||
});
|
||||
|
||||
_.each(constraints, function (constraint) {
|
||||
// Check that the package exists.
|
||||
doOrDie(function () {
|
||||
@@ -1911,17 +1901,19 @@ main.registerCommand({
|
||||
});
|
||||
|
||||
// If the version was specified, check that the version exists.
|
||||
if (constraint.version !== null) {
|
||||
var versionInfo = doOrDie(function () {
|
||||
return catalog.complete.getVersion(constraint.name, constraint.version);
|
||||
});
|
||||
if (! versionInfo) {
|
||||
process.stderr.write(
|
||||
constraint.name + "@" + constraint.version + ": no such version\n");
|
||||
failed = true;
|
||||
return;
|
||||
_.each(constraint.constraint, function (constr) {
|
||||
if (constr.version !== null) {
|
||||
var versionInfo = doOrDie(function () {
|
||||
return catalog.complete.getVersion(constraint.name, constr.version);
|
||||
});
|
||||
if (! versionInfo) {
|
||||
process.stderr.write(
|
||||
constraint.name + "@" + constr.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, but don't
|
||||
// fail. Rejecting the entire command because a part of it is a no-op is
|
||||
@@ -1956,9 +1948,15 @@ main.registerCommand({
|
||||
// Now remove the old constraint from what we're going to calculate
|
||||
// with.
|
||||
// This matches code in calculateCombinedConstraints.
|
||||
var oldConstraint = _.extend(
|
||||
{packageName: constraint.name},
|
||||
utils.parseVersionConstraint(packages[constraint.name]));
|
||||
// XXX: This is the weirdest hack, all around.
|
||||
var oldConstraint = "";
|
||||
if (constraint.constraintString) {
|
||||
oldConstraint = "@" + packages[constraint.name];
|
||||
}
|
||||
oldConstraint =
|
||||
_.extend({packageName: constraint.name},
|
||||
utils.parseConstraint(constraint.name + oldConstraint));
|
||||
|
||||
var removed = false;
|
||||
for (var i = 0; i < allPackages.length; ++i) {
|
||||
if (_.isEqual(oldConstraint, allPackages[i])) {
|
||||
@@ -1980,10 +1978,13 @@ main.registerCommand({
|
||||
|
||||
// Also, add it to all of our combined dependencies.
|
||||
// This matches code in project.calculateCombinedConstraints.
|
||||
var constraintForResolver = _.extend(
|
||||
{ packageName: constraint.name },
|
||||
utils.parseVersionConstraint(constraint.constraintString));
|
||||
allPackages.push(constraintForResolver);
|
||||
if (constraint.constraintString) {
|
||||
oldConstraint = "@" + packages[constraint.name];
|
||||
}
|
||||
allPackages.push(
|
||||
_.extend({packageName: constraint.name},
|
||||
utils.parseConstraint(constraint.name + oldConstraint)));
|
||||
|
||||
});
|
||||
|
||||
// If the user asked for invalid packages, then the user probably expects a
|
||||
@@ -2042,17 +2043,13 @@ main.registerCommand({
|
||||
if (ret !== 0) return ret;
|
||||
|
||||
// Show the user the messageLog of the packages that they installed.
|
||||
// (XXX: this will be rewritten pending geoff's feedback on packaging UX)
|
||||
process.stdout.write("\n");
|
||||
_.each(constraints, function (constraint) {
|
||||
var version = newVersions[constraint.name];
|
||||
var versionRecord = doOrDie(function () {
|
||||
return 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.name +
|
||||
(versionRecord.description ?
|
||||
(": " + versionRecord.description) :
|
||||
|
||||
@@ -179,7 +179,11 @@ var determineBuildTimeDependencies = function (packageSource,
|
||||
var constraints_array = [];
|
||||
_.each(dependencyMetadata, function (info, packageName) {
|
||||
constraints[packageName] = info.constraint;
|
||||
var version = utils.parseVersionConstraint(info.constraint || '') ;
|
||||
var constraintString = '';
|
||||
if (info.constraint) {
|
||||
constraintString = "@" + info.constraint;
|
||||
}
|
||||
var version = utils.parseConstraint(packageName + constraintString);
|
||||
constraints_array.push(_.extend({ packageName: packageName }, version));
|
||||
});
|
||||
|
||||
@@ -227,7 +231,12 @@ var determineBuildTimeDependencies = function (packageSource,
|
||||
_.each(info.use, function (spec) {
|
||||
var parsedSpec = utils.splitConstraint(spec);
|
||||
constraints[parsedSpec.package] = parsedSpec.constraint || null;
|
||||
var version = utils.parseVersionConstraint(info.constraint || '');
|
||||
|
||||
var constraintString = '';
|
||||
if (info.constraint) {
|
||||
constraintString = "@" + info.constraint;
|
||||
}
|
||||
var version = utils.parseConstraint(parsedSpec.package + constraintString);
|
||||
constraints_array.push(_.extend({packageName: parsedSpec.package},
|
||||
version));
|
||||
});
|
||||
|
||||
@@ -444,7 +444,7 @@ _.extend(PackageSource.prototype, {
|
||||
var code = fs.readFileSync(packageJsPath);
|
||||
var packageJsHash = Builder.sha1(code);
|
||||
|
||||
var releaseRecord = null;
|
||||
var releaseRecords = [];
|
||||
var hasTests = false;
|
||||
|
||||
// Any package that depends on us needs to be rebuilt if our package.js file
|
||||
@@ -454,7 +454,7 @@ _.extend(PackageSource.prototype, {
|
||||
self.pluginWatchSet.addFile(packageJsPath, packageJsHash);
|
||||
|
||||
// == 'Package' object visible in package.js ==
|
||||
|
||||
|
||||
/**
|
||||
* @global
|
||||
* @name Package
|
||||
@@ -470,7 +470,7 @@ _.extend(PackageSource.prototype, {
|
||||
// There used to be a third option documented here,
|
||||
// 'environments', but it was never implemented and no package
|
||||
// ever used it.
|
||||
|
||||
|
||||
/**
|
||||
* @summary Provide basic package information.
|
||||
* @locus package.js
|
||||
@@ -633,7 +633,7 @@ _.extend(PackageSource.prototype, {
|
||||
};
|
||||
|
||||
// == 'Npm' object visible in package.js ==
|
||||
|
||||
|
||||
/**
|
||||
* @namespace Npm
|
||||
* @global
|
||||
@@ -686,7 +686,7 @@ _.extend(PackageSource.prototype, {
|
||||
|
||||
npmDependencies = _npmDependencies;
|
||||
},
|
||||
|
||||
|
||||
require: function (name) {
|
||||
var nodeModuleDir = path.join(self.sourceRoot,
|
||||
'.npm', 'package', 'node_modules', name);
|
||||
@@ -708,7 +708,7 @@ _.extend(PackageSource.prototype, {
|
||||
};
|
||||
|
||||
// == 'Cordova' object visible in package.js ==
|
||||
|
||||
|
||||
/**
|
||||
* @namespace Cordova
|
||||
* @global
|
||||
@@ -718,7 +718,7 @@ _.extend(PackageSource.prototype, {
|
||||
/**
|
||||
* @summary Specify which [Cordova / PhoneGap](http://cordova.apache.org/)
|
||||
* plugins your Meteor package depends on.
|
||||
*
|
||||
*
|
||||
* Plugins are installed from
|
||||
* [plugins.cordova.io](http://plugins.cordova.io/), so the plugins and
|
||||
* versions specified must exist there. Alternatively, the version
|
||||
@@ -744,7 +744,7 @@ _.extend(PackageSource.prototype, {
|
||||
* "https://github.com/apache/cordova-plugin-camera/tarball/d84b875c"
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* @locus package.js
|
||||
* @memberOf Cordova
|
||||
*/
|
||||
@@ -998,7 +998,7 @@ _.extend(PackageSource.prototype, {
|
||||
// its plugins. (Has the same limitation as "unordered" that this
|
||||
// flag is not tracked per-environment or per-role; this may
|
||||
// change.)
|
||||
|
||||
|
||||
/**
|
||||
* @memberOf PackageAPI
|
||||
* @instance
|
||||
@@ -1006,7 +1006,7 @@ _.extend(PackageSource.prototype, {
|
||||
* @locus package.js
|
||||
* @param {String|String[]} packageNames Packages being depended on.
|
||||
* Package names may be suffixed with an @version tag.
|
||||
*
|
||||
*
|
||||
* In general, you must specify a package's version (e.g.,
|
||||
* `'accounts@1.0.0'` to use version 1.0.0 or a higher
|
||||
* compatible version (ex: 1.0.1, 1.5.0, etc.) of the
|
||||
@@ -1083,7 +1083,7 @@ _.extend(PackageSource.prototype, {
|
||||
// Called when this package wants packages using it to also use
|
||||
// another package. eg, for umbrella packages which want packages
|
||||
// using them to also get symbols or plugins from their components.
|
||||
|
||||
|
||||
/**
|
||||
* @memberOf PackageAPI
|
||||
* @summary Give users of this package access to another package (by passing in the string `packagename`) or a collection of packages (by passing in an array of strings [`packagename1`, `packagename2`]
|
||||
@@ -1122,7 +1122,7 @@ _.extend(PackageSource.prototype, {
|
||||
// Top-level call to add a source file to a package. It will
|
||||
// be processed according to its extension (eg, *.coffee
|
||||
// files will be compiled to JavaScript).
|
||||
|
||||
|
||||
/**
|
||||
* @memberOf PackageAPI
|
||||
* @instance
|
||||
@@ -1148,7 +1148,7 @@ _.extend(PackageSource.prototype, {
|
||||
// Use this release to resolve unclear dependencies for this package. If
|
||||
// you don't fill in dependencies for some of your implies/uses, we will
|
||||
// look at the packages listed in the release to figure that out.
|
||||
|
||||
|
||||
/**
|
||||
* @memberOf PackageAPI
|
||||
* @instance
|
||||
@@ -1156,14 +1156,7 @@ _.extend(PackageSource.prototype, {
|
||||
* @locus package.js
|
||||
* @param {String} meteorRelease Specification of a release: track@version. Just 'version' (ex: `"0.9.0"`) is sufficient if using the default release track
|
||||
*/
|
||||
versionsFrom: function (release) {
|
||||
if (releaseRecord) {
|
||||
buildmessage.error("api.versionsFrom may only be specified once.",
|
||||
{ useMyCaller: true });
|
||||
// recover by ignoring
|
||||
return;
|
||||
}
|
||||
|
||||
versionsFrom: function (releases) {
|
||||
// Uniloaded packages really ought to be in the core release, by
|
||||
// definition, so saying that they should use versions from another
|
||||
// release doesn't make sense. Moreover, if we're running from a
|
||||
@@ -1176,22 +1169,31 @@ _.extend(PackageSource.prototype, {
|
||||
return;
|
||||
}
|
||||
|
||||
// If you don't specify a track, use our default.
|
||||
if (release.indexOf('@') === -1) {
|
||||
release = catalog.DEFAULT_TRACK + "@" + release;
|
||||
}
|
||||
releases = toArray(releases);
|
||||
|
||||
var relInf = release.split('@');
|
||||
if (relInf.length !== 2) {
|
||||
buildmessage.error("Release names in versionsFrom may not contain '@'.",
|
||||
{ useMyCaller: true });
|
||||
return;
|
||||
// using for loop rather than underscore to help with useMyCaller
|
||||
for (var i = 0; i < releases.length; ++i) {
|
||||
var release = releases[i];
|
||||
|
||||
// If you don't specify a track, use our default.
|
||||
if (release.indexOf('@') === -1) {
|
||||
release = catalog.DEFAULT_TRACK + "@" + release;
|
||||
}
|
||||
|
||||
var relInf = release.split('@');
|
||||
if (relInf.length !== 2) {
|
||||
buildmessage.error("Release names in versionsFrom may not contain '@'.",
|
||||
{ useMyCaller: true });
|
||||
return;
|
||||
}
|
||||
var releaseRecord = catalog.official.getReleaseVersion(
|
||||
relInf[0], relInf[1]);
|
||||
if (!releaseRecord) {
|
||||
buildmessage.error("Unknown release "+ release);
|
||||
} else {
|
||||
releaseRecords.push(releaseRecord);
|
||||
}
|
||||
}
|
||||
releaseRecord = catalog.official.getReleaseVersion(
|
||||
relInf[0], relInf[1]);
|
||||
if (!releaseRecord) {
|
||||
buildmessage.error("Unknown release "+ release);
|
||||
}
|
||||
},
|
||||
|
||||
// Export symbols from this package.
|
||||
@@ -1201,7 +1203,7 @@ _.extend(PackageSource.prototype, {
|
||||
// or an array of those.
|
||||
// The default is ['web', 'server'].
|
||||
// @param options 'testOnly', boolean.
|
||||
|
||||
|
||||
/**
|
||||
* @memberOf PackageAPI
|
||||
* @instance
|
||||
@@ -1262,20 +1264,31 @@ _.extend(PackageSource.prototype, {
|
||||
}
|
||||
}
|
||||
|
||||
// If we have specified a release, then we should go through the
|
||||
// If we have specified some release, then we should go through the
|
||||
// dependencies and fill in the unspecified constraints with the versions in
|
||||
// the release (if possible).
|
||||
if (releaseRecord) {
|
||||
var packages = releaseRecord.packages;
|
||||
// the releases (if possible).
|
||||
if (!_.isEmpty(releaseRecords)) {
|
||||
console.log(releaseRecords);
|
||||
|
||||
// Given a dependency object with keys package (the name of the package)
|
||||
// and constraint (the version constraint), if the constraint is null,
|
||||
// look in the packages field in the release record and fill in from
|
||||
// there.
|
||||
var setFromRel = function (dep) {
|
||||
if (! dep.constraint && _.has(packages, dep.package)) {
|
||||
dep.constraint = packages[dep.package];
|
||||
};
|
||||
if (dep.constraint) {
|
||||
return dep;
|
||||
}
|
||||
var newConstraint = [];
|
||||
_.each(releaseRecords, function (releaseRecord) {
|
||||
var packages = releaseRecord.packages;
|
||||
if(_.has(packages, dep.package)) {
|
||||
newConstraint.push(dep.package);
|
||||
}
|
||||
});
|
||||
dep.constraint = _.reduce(newConstraint,
|
||||
function(x, y) {
|
||||
return x + " || " + y;
|
||||
});
|
||||
return dep;
|
||||
};
|
||||
|
||||
|
||||
@@ -113,10 +113,12 @@ PV.compare = function (versionOne, versionTwo) {
|
||||
// version has been explicitly selected (which at this stage in the game
|
||||
// means they are mentioned in a top-level constraint in the top-level
|
||||
// call to the resolver).
|
||||
//
|
||||
// Options:
|
||||
// removeBuildIDs: Remove the build ID at the end of the version.
|
||||
PV.parseVersionConstraint = function (versionString, options) {
|
||||
options = options || {};
|
||||
var versionDesc = { version: null, type: "any-reasonable",
|
||||
constraintString: versionString };
|
||||
var versionDesc = { version: null, type: "any-reasonable" };
|
||||
|
||||
if (!versionString) {
|
||||
return versionDesc;
|
||||
@@ -132,6 +134,10 @@ PV.parseVersionConstraint = function (versionString, options) {
|
||||
// This will throw if the version string is invalid.
|
||||
PV.getValidServerVersion(versionString);
|
||||
|
||||
if (options.removeBuildIDs) {
|
||||
versionString = versionString.replace(/\+.*$/, '');
|
||||
}
|
||||
|
||||
versionDesc.version = versionString;
|
||||
|
||||
return versionDesc;
|
||||
@@ -180,8 +186,6 @@ PV.parseConstraint = function (constraintString, options) {
|
||||
|
||||
var splitted = constraintString.split('@');
|
||||
|
||||
var constraint = { name: "", version: null,
|
||||
type: "any-reasonable", constraintString: null };
|
||||
var name = splitted[0];
|
||||
var versionString = splitted[1];
|
||||
|
||||
@@ -189,9 +193,17 @@ PV.parseConstraint = function (constraintString, options) {
|
||||
// throw error complaining about @
|
||||
PV.validatePackageName('a@');
|
||||
}
|
||||
PV.validatePackageName(name);
|
||||
|
||||
constraint.name = name;
|
||||
if (options.archesOK) {
|
||||
var newNames = name.split('#');
|
||||
if (newNames.length > 2) {
|
||||
// It is invalid and should register as such. This will throw.
|
||||
PV.validatePackageName(name);
|
||||
}
|
||||
PV.validatePackageName(newNames[0]);
|
||||
} else {
|
||||
PV.validatePackageName(name);
|
||||
}
|
||||
|
||||
if (splitted.length === 2 && !versionString) {
|
||||
throwVersionParserError(
|
||||
@@ -200,11 +212,29 @@ PV.parseConstraint = function (constraintString, options) {
|
||||
"the version.");
|
||||
}
|
||||
|
||||
if (versionString) {
|
||||
__.extend(constraint,
|
||||
PV.parseVersionConstraint(versionString, options));
|
||||
var constraint = {
|
||||
name: name
|
||||
};
|
||||
|
||||
// Before we parse through versionString, we save it for future output.
|
||||
constraint.constraintString = versionString;
|
||||
|
||||
// If we did not specify a version string, then our only constraint is
|
||||
// any-reasonable, so we are going to return that.
|
||||
if (!versionString) {
|
||||
constraint.constraints =
|
||||
[ { version: null, type: "any-reasonable" } ];
|
||||
return constraint;
|
||||
}
|
||||
|
||||
// Let's parse out the versionString.
|
||||
var versionConstraints = versionString.split(' || ');
|
||||
constraint.constraints = [];
|
||||
__.each(versionConstraints, function (versionCon) {
|
||||
constraint.constraints.push(
|
||||
PV.parseVersionConstraint(versionCon, options));
|
||||
});
|
||||
|
||||
return constraint;
|
||||
};
|
||||
|
||||
@@ -238,19 +268,6 @@ var throwVersionParserError = function (message) {
|
||||
throw e;
|
||||
};
|
||||
|
||||
// XXX if we were better about consistently only using functions in this file,
|
||||
// we could just do this using the constraintString field
|
||||
PV.constraintToVersionString = function (parsedConstraint) {
|
||||
if (parsedConstraint.type === "any-reasonable")
|
||||
return "";
|
||||
if (parsedConstraint.type === "compatible-with")
|
||||
return parsedConstraint.version;
|
||||
if (parsedConstraint.type === "exactly")
|
||||
return "=" + parsedConstraint.version;
|
||||
throw Error("Unknown constraint type: " + parsedConstraint.type);
|
||||
};
|
||||
|
||||
PV.constraintToFullString = function (parsedConstraint) {
|
||||
return parsedConstraint.name + "@" + PV.constraintToVersionString(
|
||||
parsedConstraint);
|
||||
return parsedConstraint.name + "@" + parsedConstraint.constraintString;
|
||||
};
|
||||
|
||||
@@ -270,11 +270,15 @@ _.extend(Project.prototype, {
|
||||
// self.constraints variable is always up to date.
|
||||
// Note that two parts of the "add" command run code that matches this.
|
||||
_.each(self.constraints, function (constraint, packageName) {
|
||||
allDeps.push(_.extend({packageName: packageName},
|
||||
utils.parseVersionConstraint(constraint)));
|
||||
var oldConstraint = "";
|
||||
if (constraint) {
|
||||
oldConstraint = "@" + constraint;
|
||||
}
|
||||
allDeps.push(
|
||||
_.extend({packageName: packageName},
|
||||
utils.parseConstraint(packageName + oldConstraint)));
|
||||
});
|
||||
|
||||
|
||||
// Now we have to go through the programs directory, go through each of the
|
||||
// programs, get their dependencies and use them. (We could have memorized
|
||||
// this value, but this is called very rarely outside the first
|
||||
@@ -294,20 +298,23 @@ _.extend(Project.prototype, {
|
||||
programSource.initFromPackageDir(programSubdir);
|
||||
_.each(programSource.architectures, function (sourceUnibuild) {
|
||||
_.each(sourceUnibuild.uses, function (use) {
|
||||
var constraint = use.constraint || null;
|
||||
allDeps.push(_.extend({packageName: use.package},
|
||||
utils.parseVersionConstraint(constraint)));
|
||||
var oldConstraint = "";
|
||||
if (use.constraint) {
|
||||
oldConstraint = "@" + use.constraint;
|
||||
}
|
||||
allDeps.push(
|
||||
_.extend({packageName: use.package},
|
||||
utils.parseConstraint(use.packageName + oldConstraint)));
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// Finally, each release package is a weak exact constraint. So, let's add
|
||||
// those.
|
||||
_.each(releasePackages, function(version, name) {
|
||||
allDeps.push({packageName: name, version: version, weak: true,
|
||||
type: 'exactly'});
|
||||
allDeps.push({packageName: name, weak: true, constraints: [
|
||||
{ version: version, type: 'exactly' } ]});
|
||||
});
|
||||
|
||||
// This is an UGLY HACK that has to do with our requirement to have a
|
||||
@@ -316,7 +323,8 @@ _.extend(Project.prototype, {
|
||||
// someday, this will make sense. (The conditional here allows us to work
|
||||
// in tests with releases that have no packages.)
|
||||
if (catalog.complete.getPackage("ctl")) {
|
||||
allDeps.push({packageName: "ctl", version: null, type: 'any-reasonable'});
|
||||
allDeps.push({packageName: "ctl", constraints: [
|
||||
{ version: null, type: 'any-reasonable' } ]});
|
||||
}
|
||||
|
||||
return allDeps;
|
||||
|
||||
@@ -1,52 +1,53 @@
|
||||
application-configuration@1.0.1
|
||||
application-configuration@1.0.2
|
||||
autopublish@1.0.0
|
||||
autoupdate@1.0.7-cordova6
|
||||
autoupdate@1.1.0
|
||||
base64@1.0.0
|
||||
binary-heap@1.0.0
|
||||
blaze-tools@1.0.0
|
||||
blaze@2.0.0
|
||||
boilerplate-generator@1.0.0-cordova1
|
||||
boilerplate-generator@1.0.0
|
||||
callback-hook@1.0.0
|
||||
check@1.0.0
|
||||
ctl-helper@1.0.3
|
||||
ctl@1.0.1
|
||||
ddp@1.0.8
|
||||
deps@1.0.3
|
||||
ejson@1.0.1
|
||||
fastclick@1.0.0-cordova1
|
||||
ejson@1.0.2
|
||||
fastclick@1.0.0
|
||||
follower-livedata@1.0.1
|
||||
geojson-utils@1.0.0
|
||||
html-tools@1.0.0
|
||||
htmljs@1.0.0-cordova1
|
||||
http@1.0.4
|
||||
htmljs@1.0.1
|
||||
http@1.0.5
|
||||
id-map@1.0.0
|
||||
insecure@1.0.0
|
||||
jquery@1.0.0
|
||||
json@1.0.0
|
||||
livedata@1.0.9
|
||||
logging@1.0.2-cordova2
|
||||
meteor-platform@1.0.2
|
||||
meteor@1.0.4-cordova6
|
||||
minifiers@1.0.2
|
||||
minimongo@1.0.2
|
||||
mobile-status-bar@1.0.0-cordova2
|
||||
mongo@1.0.4
|
||||
logging@1.0.3
|
||||
meteor-platform@1.1.0
|
||||
meteor@1.1.0
|
||||
minifiers@1.1.0
|
||||
minimongo@1.0.3
|
||||
mobile-status-bar@1.0.0
|
||||
mongo@1.0.5
|
||||
observe-sequence@1.0.2
|
||||
ordered-dict@1.0.0
|
||||
random@1.0.0
|
||||
reactive-dict@1.0.2
|
||||
reactive-var@1.0.1
|
||||
reload@1.0.1
|
||||
reload@1.1.0
|
||||
retry@1.0.0
|
||||
routepolicy@1.0.0-cordova1
|
||||
routepolicy@1.0.1
|
||||
session@1.0.1
|
||||
spacebars-compiler@1.0.2
|
||||
spacebars@1.0.1
|
||||
standard-app-packages@1.0.1
|
||||
templating@1.0.5
|
||||
templating@1.0.6
|
||||
test-package@1.0.0
|
||||
tracker@1.0.2
|
||||
ui@1.0.2
|
||||
underscore@1.0.0
|
||||
url@1.0.0
|
||||
webapp-hashing@1.0.0-cordova1
|
||||
webapp@1.0.3
|
||||
webapp-hashing@1.0.0
|
||||
webapp@1.1.1
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"dependencies": [
|
||||
[
|
||||
"meteor",
|
||||
"1.0.4-cordova6"
|
||||
"1.1.0"
|
||||
],
|
||||
[
|
||||
"underscore",
|
||||
|
||||
@@ -1,52 +1,53 @@
|
||||
application-configuration@1.0.1
|
||||
application-configuration@1.0.2
|
||||
autopublish@1.0.0
|
||||
autoupdate@1.0.7-cordova6
|
||||
autoupdate@1.1.0
|
||||
base64@1.0.0
|
||||
binary-heap@1.0.0
|
||||
blaze-tools@1.0.0
|
||||
blaze@2.0.0
|
||||
boilerplate-generator@1.0.0-cordova1
|
||||
boilerplate-generator@1.0.0
|
||||
callback-hook@1.0.0
|
||||
check@1.0.0
|
||||
ctl-helper@1.0.3
|
||||
ctl@1.0.1
|
||||
ddp@1.0.8
|
||||
deps@1.0.3
|
||||
ejson@1.0.1
|
||||
fastclick@1.0.0-cordova1
|
||||
ejson@1.0.2
|
||||
fastclick@1.0.0
|
||||
follower-livedata@1.0.1
|
||||
geojson-utils@1.0.0
|
||||
html-tools@1.0.0
|
||||
htmljs@1.0.0-cordova1
|
||||
http@1.0.4
|
||||
htmljs@1.0.1
|
||||
http@1.0.5
|
||||
id-map@1.0.0
|
||||
insecure@1.0.0
|
||||
jquery@1.0.0
|
||||
json@1.0.0
|
||||
livedata@1.0.9
|
||||
logging@1.0.2-cordova2
|
||||
meteor-platform@1.0.2
|
||||
meteor@1.0.4-cordova6
|
||||
minifiers@1.0.2
|
||||
minimongo@1.0.2
|
||||
mobile-status-bar@1.0.0-cordova2
|
||||
mongo@1.0.4
|
||||
logging@1.0.3
|
||||
meteor-platform@1.1.0
|
||||
meteor@1.1.0
|
||||
minifiers@1.1.0
|
||||
minimongo@1.0.3
|
||||
mobile-status-bar@1.0.0
|
||||
mongo@1.0.5
|
||||
observe-sequence@1.0.2
|
||||
ordered-dict@1.0.0
|
||||
preserve-inputs@1.0.0
|
||||
random@1.0.0
|
||||
reactive-dict@1.0.2
|
||||
reactive-var@1.0.1
|
||||
reload@1.0.1
|
||||
reload@1.1.0
|
||||
retry@1.0.0
|
||||
routepolicy@1.0.0-cordova1
|
||||
routepolicy@1.0.1
|
||||
session@1.0.1
|
||||
spacebars-compiler@1.0.2
|
||||
spacebars@1.0.1
|
||||
standard-app-packages@1.0.1
|
||||
templating@1.0.5
|
||||
templating@1.0.6
|
||||
tracker@1.0.2
|
||||
ui@1.0.2
|
||||
underscore@1.0.0
|
||||
url@1.0.0
|
||||
webapp-hashing@1.0.0-cordova1
|
||||
webapp@1.0.3
|
||||
webapp-hashing@1.0.0
|
||||
webapp@1.1.1
|
||||
|
||||
@@ -1,49 +1,50 @@
|
||||
application-configuration@1.0.1
|
||||
autoupdate@1.0.7-cordova6
|
||||
application-configuration@1.0.2
|
||||
autoupdate@1.1.0
|
||||
base64@1.0.0
|
||||
binary-heap@1.0.0
|
||||
blaze-tools@1.0.0
|
||||
blaze@2.0.0
|
||||
boilerplate-generator@1.0.0-cordova1
|
||||
boilerplate-generator@1.0.0
|
||||
callback-hook@1.0.0
|
||||
check@1.0.0
|
||||
ctl-helper@1.0.3
|
||||
ctl@1.0.1
|
||||
ddp@1.0.8
|
||||
deps@1.0.3
|
||||
ejson@1.0.1
|
||||
fastclick@1.0.0-cordova1
|
||||
ejson@1.0.2
|
||||
fastclick@1.0.0
|
||||
follower-livedata@1.0.1
|
||||
geojson-utils@1.0.0
|
||||
html-tools@1.0.0
|
||||
htmljs@1.0.0-cordova1
|
||||
http@1.0.4
|
||||
htmljs@1.0.1
|
||||
http@1.0.5
|
||||
id-map@1.0.0
|
||||
jquery@1.0.0
|
||||
json@1.0.0
|
||||
livedata@1.0.9
|
||||
logging@1.0.2-cordova2
|
||||
meteor-platform@1.0.2
|
||||
meteor@1.0.4-cordova6
|
||||
minifiers@1.0.2
|
||||
minimongo@1.0.2
|
||||
mobile-status-bar@1.0.0-cordova2
|
||||
mongo@1.0.4
|
||||
logging@1.0.3
|
||||
meteor-platform@1.1.0
|
||||
meteor@1.1.0
|
||||
minifiers@1.1.0
|
||||
minimongo@1.0.3
|
||||
mobile-status-bar@1.0.0
|
||||
mongo@1.0.5
|
||||
observe-sequence@1.0.2
|
||||
ordered-dict@1.0.0
|
||||
random@1.0.0
|
||||
reactive-dict@1.0.2
|
||||
reactive-var@1.0.1
|
||||
reload@1.0.1
|
||||
reload@1.1.0
|
||||
retry@1.0.0
|
||||
routepolicy@1.0.0-cordova1
|
||||
routepolicy@1.0.1
|
||||
session@1.0.1
|
||||
spacebars-compiler@1.0.2
|
||||
spacebars@1.0.1
|
||||
standard-app-packages@1.0.1
|
||||
templating@1.0.5
|
||||
templating@1.0.6
|
||||
tracker@1.0.2
|
||||
ui@1.0.2
|
||||
underscore@1.0.0
|
||||
url@1.0.0
|
||||
webapp-hashing@1.0.0-cordova1
|
||||
webapp@1.0.3
|
||||
webapp-hashing@1.0.0
|
||||
webapp@1.1.1
|
||||
|
||||
@@ -251,8 +251,8 @@ selftest.define("add packages to app", ["net"], function () {
|
||||
["accounts-base",
|
||||
"meteor-platform"]);
|
||||
run = s.run("list");
|
||||
run.match("meteor-platform");
|
||||
run.match("accounts-base");
|
||||
run.match("meteor-platform");
|
||||
|
||||
// Add packages to sub-programs of an app. Make sure that the correct change
|
||||
// is propagated to its versions file.
|
||||
@@ -260,8 +260,8 @@ selftest.define("add packages to app", ["net"], function () {
|
||||
|
||||
// Don't add the file to packages.
|
||||
run = s.run("list");
|
||||
run.match("meteor-platform");
|
||||
run.match("accounts-base");
|
||||
run.match("meteor-platform");
|
||||
|
||||
// Do add the file to versions.
|
||||
checkVersions(s,
|
||||
@@ -614,8 +614,8 @@ selftest.define("package with --name", ['test-package-server'], function () {
|
||||
run.stop();
|
||||
|
||||
run = s.run('list');
|
||||
run.match("meteor");
|
||||
run.match("accounts-base");
|
||||
run.match("meteor");
|
||||
|
||||
// What about test-packages?
|
||||
s.cd('packages');
|
||||
|
||||
Reference in New Issue
Block a user