Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to newer semver, fixes #1817,#1845,#1851 #1852

Merged
merged 1 commit into from
Jul 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"request-progress": "0.3.1",
"retry": "0.6.1",
"rimraf": "^2.2.8",
"semver": "^2.3.0",
"semver": "^5.0.1",
"shell-quote": "^1.4.2",
"stringify-object": "^1.0.0",
"tar-fs": "^1.4.1",
Expand Down
32 changes: 31 additions & 1 deletion test/core/resolveCache.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ describe('ResolveCache', function () {
fs.mkdirSync(path.join(sourceDir, '0.1.0-rc.2'));
fs.writeFileSync(path.join(sourceDir, '0.1.0-rc.2', '.bower.json'), JSON.stringify(json, null, ' '));

resolveCache.retrieve(source, '~0.1.0')
resolveCache.retrieve(source, '~0.1.0 || ~0.1.0-rc.0')
.spread(function (canonicalDir, pkgMeta) {
expect(pkgMeta).to.be.an('object');
expect(pkgMeta.version).to.equal('0.1.0-rc.2');
Expand All @@ -524,6 +524,36 @@ describe('ResolveCache', function () {
.done();
});

it('should resolve to the highest package that matches an x-range target, ignoring pre-releases versions', function (next) {
var source = String(Math.random());
var sourceId = md5(source);
var sourceDir = path.join(cacheDir, sourceId);
var json = { name: 'foo' };

// Create some versions
fs.mkdirSync(sourceDir);

// fix #1817 : >=1.2.x <=1.4.x which resolved to 1.3.16

json.version = '1.3.16-rc.1';
fs.mkdirSync(path.join(sourceDir, json.version));
fs.writeFileSync(path.join(sourceDir, json.version, '.bower.json'), JSON.stringify(json, null, ' '));

json.version = '1.3.16';
fs.mkdirSync(path.join(sourceDir, json.version));
fs.writeFileSync(path.join(sourceDir, json.version, '.bower.json'), JSON.stringify(json, null, ' '));

resolveCache.retrieve(source, '>=1.2.x <=1.4.x')
.spread(function (canonicalDir, pkgMeta) {
expect(pkgMeta).to.be.an('object');
expect(pkgMeta.version).to.equal('1.3.16');
expect(canonicalDir).to.equal(path.join(sourceDir, '1.3.16'));

next();
})
.done();
});

it('should resolve to exact match (including build metadata) if available', function (next) {
var source = String(Math.random());
var sourceId = md5(source);
Expand Down
31 changes: 28 additions & 3 deletions test/core/resolvers/gitResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ describe('GitResolver', function () {
.done();
});

it('should resolve "*" to the latest version if a repository has valid semver tags, not ignoring pre-releases if they are the only versions', function (next) {
it('should fail to resolve "*" if a repository has valid semver tags, ignoring pre-releases if they are the only versions', function (next) {
var resolver;

GitResolver.refs = function () {
Expand All @@ -519,6 +519,31 @@ describe('GitResolver', function () {

resolver = create('foo');
resolver._findResolution('*')
.then(function () {
next(new Error('Should have failed'));
}, function (err) {
expect(err).to.be.an(Error);
expect(err.message).to.match(/no tag found that was able to satisfy/i);
expect(err.details).to.match(/0.1.0-rc/i);
expect(err.code).to.equal('ENORESTARGET');
next();
})
.done();
});

it('should resolve "* || >=0.1.0-rc.0" to the latest version if a repository has valid semver tags, not ignoring pre-releases if they are the only versions', function (next) {
var resolver;

GitResolver.refs = function () {
return Q.resolve([
'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa refs/heads/master',
'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb refs/tags/0.1.0-rc.1',
'cccccccccccccccccccccccccccccccccccccccc refs/tags/0.1.0-rc.2'
]);
};

resolver = create('foo');
resolver._findResolution('* || >=0.1.0-rc.0')
.then(function (resolution) {
expect(resolution).to.eql({
type: 'version',
Expand All @@ -542,7 +567,7 @@ describe('GitResolver', function () {
};

resolver = create('foo');
resolver._findResolution('0.1.*')
resolver._findResolution('0.1.* || >=0.1.0-rc.1')
.then(function (resolution) {
expect(resolution).to.eql({
type: 'version',
Expand Down Expand Up @@ -642,7 +667,7 @@ describe('GitResolver', function () {
};

resolver = create('foo');
resolver._findResolution('~0.2.1')
resolver._findResolution('~0.2.1-rc.0')
.then(function (resolution) {
expect(resolution).to.eql({
type: 'version',
Expand Down
28 changes: 26 additions & 2 deletions test/core/resolvers/svnResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ else describe('SvnResolver', function () {
.done();
});

it('should resolve "*" to the latest version if a repository has valid semver tags, not ignoring pre-releases if they are the only versions', function (next) {
it('should fail to resolve "*" if a repository has valid semver tags, ignoring pre-releases if they are the only versions', function (next) {
var resolver;

SvnResolver.tags = function () {
Expand All @@ -374,6 +374,30 @@ else describe('SvnResolver', function () {

resolver = create('foo');
resolver._findResolution('*')
.then(function () {
next(new Error('Should have failed'));
}, function (err) {
expect(err).to.be.an(Error);
expect(err.message).to.match(/no tag found that was able to satisfy/i);
expect(err.details).to.match(/0.1.0-rc/i);
expect(err.code).to.equal('ENORESTARGET');
next();
})
.done();
});

it('should resolve "*" to the latest version if a repository has valid semver tags, not ignoring pre-releases if they are the only versions', function (next) {
var resolver;

SvnResolver.tags = function () {
return Q.resolve({
'0.1.0-rc.1': 1,
'0.1.0-rc.2': 2
});
};

resolver = create('foo');
resolver._findResolution('* || >=0.1.0-rc.0')
.then(function (resolution) {
expect(resolution).to.eql({
type: 'version',
Expand Down Expand Up @@ -445,7 +469,7 @@ else describe('SvnResolver', function () {
};

resolver = create('foo');
resolver._findResolution('~0.2.1')
resolver._findResolution('~0.2.1 || ~0.2.1-rc.0')
.then(function (resolution) {
expect(resolution).to.eql({
type: 'version',
Expand Down