Commit Graph

37 Commits

Author SHA1 Message Date
David Greenspan
d05db2b327 Fix PVP tests 2016-02-05 12:13:42 -08:00
Sashko Stubailo
efdfe62331 Validate number of colons in package name on create
Instead of in the general package version parser
2015-03-17 10:56:33 -07:00
Sashko Stubailo
c6ea68f9b3 Make meteor create --package not use prefix
It used to create a directory with an underscore instead of a colon
Now, it just removes the prefix.

In cases where the name of the package has more than one colon or starts or ends
witha colon, we report an error.
2015-03-12 17:57:27 -07:00
David Greenspan
070ca69f9a Validate package names more strictly
In particular, ban leading `-`, trailing `.`, and `..` anywhere.

This backport commit drops the changes to constraint-solver and adds a
History.md note.
2015-03-10 15:20:36 -07:00
David Greenspan
45752e3203 parseConstraint -> parsePackageConstraint
In the return value, `name` has been changed to `package`,
and `vConstraint` is now `versionConstraint`.

`constraint.package` is better than `constraint.name`, where
`constraint` is a PackageConstraint.  It's also more consistent
with functions like parsePackageAtVersion which return an object
like `{package, version}`.

`vConstraint` was too cryptic.

Changes were discussed with Glasser in a code review.

Troposphere does not call parseConstraint or work with constraint
objects, so it doesn't need to change.

This is a breaking change to the package-version-parser API (or one
method of it, at least), but it is considered an internal API so we
are not worrying too much about it.
2015-02-02 13:13:31 -08:00
David Greenspan
361a80c243 Changes from Glasser code review
Includes all discussed changes except:
- Checking for troposphere PVP compatibility
- "vConstraint" -> "versionConstraint"
- "name" -> "package" in utils.parsePackageAtVersion
2015-01-28 16:45:01 -08:00
David Greenspan
9d9dec602f Use the CatalogLoader in PackageResolver
PackageResolver no longer loads data from the Catalog.  Instead, it
tells CatalogLoader what to load, and it sets up the Resolver based
on what it finds in the CatalogCache.

PackageResolver now creates the Resolver inside resolve(…).  If the tool
were to invoke resolve(…) multiple times on the same PackageResolver
(which it doesn’t at the moment), the CatalogCache would persist, but
not the Resolver.  (Note that PackageResolver#resolve makes multiple
calls to the same Resolver#resolve internally.)

The purpose of this change is to stop using Resolver to store the
dependency graph.  Resolver will be replaced with a logic-solver-based
implementation that will not represent the graph as is, but instead
encode the graph as a satisfiability problem.  Meanwhile, CatalogCache
is better at storing the graph than Resolver was, because it is easy
to populate, query, and serialize.

This change brings us back to a functional “devel”.
2015-01-09 10:26:06 -08:00
David Greenspan
10698d5940 PackageConstraint has a toString() 2015-01-08 13:46:59 -08:00
David Greenspan
fe8a661e2f PackageConstraint can take a VersionConstraint
also, versionConstraint.raw is always a String
2015-01-08 13:38:17 -08:00
David Greenspan
e885e78348 Change the format returned by PVP.parseConstraint
This is a breaking change to package-version-parser.

A PackageConstraint used to look like this:

```
{ name: String,
  constraintString: String,
  constraints: [{version: String|null,
                 type: String}]}
```

Now it looks like this:
```
{ name: String,
  constraintString: String,
  vConstraint: {
    raw: String,
    alternatives: [{versionString: String|null,
                    type: String}]}}
```

Where (vConstraint instanceof VersionConstraint) and
(vConstraint.raw === constraintString).

This achieves several desirable changes at once.

* `constraint.constraints` for the disjuncts in “1.0.0||2.0.0”
  was confusing.  `alternatives` is better.
* Having a class for VersionConstraint will come in handy because
  we can add methods to it, and we can use it in the constraint
  solver to represent the problem statement.
* The names “vConstraint” and “versionString” are a little verbose,
  but there really shouldn’t be a lot of code that dives into this
  structure, and I really wanted to avoid anyone ever writing:
  `constraint.constraint.alternatives[0].version`, and then wondering
  what sort of object that was (not a parsed PackageVersion! we could
  parse eagerly but that might be slow).
2015-01-07 20:10:44 -08:00
David Greenspan
f51afe18f0 Ban constraints like foo@||
Clean up parseSimpleConstraint
2015-01-07 19:27:09 -08:00
David Greenspan
184ab3bde1 PV.parseConstraint returns a PackageConstraint
Mostly I just made parseConstraint clearer and gave the return value a
prototype.

There are new unit tests, and the existing ones have been given much
better names.

PV.parseConstraint also now optionally takes two arguments, a package name and a version constraint.  We can eventually propagate this feature to the tool and stop concatenating with “@” so much.

I’m referring to “foo@=1.0.0” as a PackageConstraint and “=1.0.0” as a version constraint.  I’ll probably add a VersionConstraint class too.
2015-01-07 19:04:55 -08:00
David Greenspan
9b6087a099 PVP: Add a test 2015-01-07 15:40:38 -08:00
David Greenspan
259f90bc5a Make PVP able to parse a version (and work on client)
Despite the name “package-version-parser,” PVP didn’t really provide a way to parse a package version.  With this change, if you want to get the minor version of “1.2.3_4”, for example, you can just write `PV.parse(“1.2.3_4”).minor`.  This simplifies the internals of PVP as well.

When you parse a version, you now get an instance of PackageVersion with a documented set of fields.

Also, make PVP work on the client.  When called directly from the tool, semver is loaded the same way as before.  When PVP is used as a package, it uses a copy of semver v4.1.0 kept inside the package.

This change is intended to be 100% behavior-preserving.
2015-01-07 15:17:30 -08:00
David Glasser
44563f13b4 Allow prerelease parts with digits and nondigits
Previously the constraint solver crashed on such things.

Fixes #3147.
2014-12-09 20:33:06 -08:00
David Greenspan
3719494af3 Add a few comments 2014-11-08 20:11:01 -08:00
David Glasser
7126e17109 Allow any number of spaces by || in constraints
Previously, exactly one was required, but this was not explicitly
documented.
2014-10-09 21:20:14 -07:00
Avital Oliver
a9ea64a7c3 Allow more than one dash in package version names
This is consistent with the semver spec, and should fix
2014-09-30 11:49:43 -07:00
Nick Martin
1db094b411 Revert "Ignore packages with malformed versions or malformed constraints"
This reverts commit 8fe23b418b.
2014-09-25 11:41:56 -07:00
Avital Oliver
8fe23b418b Ignore packages with malformed versions or malformed constraints
This allows us to later increase the pool for well-formed versions without requiring
moving the catalog's data.json into a new folder, which would require re-syncing
the entire catalog.
2014-09-24 23:19:59 -07:00
Avital Oliver
2a71dbfc41 Change output range for PackageVersionParser.versionMagnitude
It's now back to returning 10000 for "1.0.0", as it was before
the recent changes to allow for wrapped package version numbers
and prerelease versions. Given that there are other constants
in the cost function used in the constraint solver, this gives
us much more confidence that we haven't fundamentally changed
the behavior of `meteor add` or `meteor update` in 0.9.3.
2014-09-24 17:44:44 -07:00
Avital Oliver
782c0ac1bb Support semver prerelease versions
The semver library's compare functions already did the right thing,
but our `PackageVersion.versionMagnitude` did not. It now almost
correctly works for prerelease versions with a few caveats described
in a [* XXX!] comment.

While at it, add many tests which caught a separate bug due to
adding a number to a string for versions such as "1.2.3_50".
(That version would have been chosen over "5.0.0"!)
2014-09-23 15:19:20 -07:00
ekatek
e35e64b30c user the underscore instead of a tilde 2014-09-22 21:57:23 -07:00
ekatek
e1311c407c function to check if a version constraint is compatible with pre0.9.3 versions, default token to send to syncNewData includes format specifications 2014-09-19 16:56:25 -07:00
ekatek
d8377487dc support multiple major versions in meteor 0.9.3 and above. A little hacky in the tool around keeping old interfaces, but it works 2014-09-18 00:12:30 -07:00
ekatek
69f637c8e5 glassers comments on wrap numbers 2014-09-10 15:53:23 -07:00
ekatek
390b6394b5 strip out extra dependencies on semver in tool 2014-09-10 15:53:23 -07:00
ekatek
8f29056b4c wrapping external library versions support in p-v-p and constraint-solver 2014-09-10 15:53:23 -07:00
David Glasser
43e01c09eb Improve treatment of prerelease (dashed) packages
Drop the "at-least" constraint type entirely. It was not user-accessible
and was only used in the form ">=0.0.0" to represent a constraint with
no version constraint at all. This type of constraint is now called
"any-reasonable".

The definition of "any-reasonable" is:

  - Any version that is not a pre-release (has no dash)
  - Or a pre-release version that is explicitly mentioned in a TOP-LEVEL
    constraint passed to the constraint solver

For example, constraints from .meteor/packages, constraints from the
release, and constraints from the command line of "meteor add" end up
being top-level.

Why only top-level-constrained pre-release versions, and not versions we
find explicitly desired by some other desired version while walking the
graph?

The constraint solver assumes that adding a constraint to the resolver
state can't make previously impossible choices now possible.  If
pre-releases mentioned anywhere worked, then applying the constraints
"any reasonable" followed by "1.2.3-rc1" would result in "1.2.3-rc1"
ruled first impossible and then possible again. That's no good, so we
have to fix the meaning based on something at the start.  (We could try
to apply our prerelease-avoidance tactics solely in the cost functions,
but then it becomes a much less strict rule.)

At the very least, this change should allow you to run meteor on a
preview branch like cordova-hcp without getting a conflict between the
prerelease package on the branch/release and the lack of an explicit
constraint in .meteor/packages on that package, because we are
reintepreting the .meteor/packages constraint as meaning "anything
reasonable" and the in-the-release version counts as reasonable.
2014-08-26 21:54:48 -07:00
David Glasser
628be93f61 fix tests that tested lies! 2014-08-21 17:09:23 -07:00
David Glasser
f39a820d96 Don't parse '@>=' ranges by default
They are still used internally by the constraint solver (to implement
update --breaking) but cannot be externally specified.

Also, stop supporting "@none", whatever that was.
2014-08-15 22:12:04 -07:00
David Glasser
e59fb948b5 fix tests broken by 6850b679e9 2014-07-30 19:24:55 -07:00
Slava Kim
98d9a56a62 Extend the number of types of constraints from 2 to 3
Instead of having a "exact" flag, have a "type" field with 3 different values
2014-05-15 18:16:30 -07:00
ekatek
f2d3972857 integration mostly works except for bizarre constraint solver output bug 2014-05-09 15:15:45 -07:00
Geoff Schmidt
985ffea9fa WIP - make package build run the constraint solver.
move constraint solver from a package into the tool.
unipackage loading is broken; next step is to fix that
2014-03-12 19:02:47 -07:00
Slava Kim
9dd40fa1db extract parseVersionConstraint from parseConstraint 2014-03-05 01:25:51 -08:00
Slava Kim
468f32bd80 package-version-parser package
first version of a package that parses smart package version string
2014-03-04 23:08:38 -08:00