This repository has been archived by the owner on Jan 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support acceptDependencies object in package.json
This treats any dep ranges in the acceptDependencies field as an acceptable alternative for any dependency range specified elsewhere in the package manifest. Implementation of npm/rfcs#72
- Loading branch information
Showing
13 changed files
with
167 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,27 +2,33 @@ const t = require('tap') | |
const depValid = require('../lib/dep-valid.js') | ||
const npa = require('npm-package-arg') | ||
|
||
t.ok(depValid({}, '', {}), '* is always ok') | ||
t.ok(depValid({}, '', null, {}), '* is always ok') | ||
|
||
t.ok(depValid({ | ||
package: { | ||
version: '1.2.3', | ||
}, | ||
}, '1.x', {}), 'range that is satisfied') | ||
}, '1.x', null, {}), 'range that is satisfied') | ||
|
||
t.ok(depValid({ | ||
package: { | ||
version: '2.2.3', | ||
}, | ||
}, '1.x', '2.x', {}), 'range that is acceptable') | ||
|
||
t.ok(depValid({ | ||
isLink: true, | ||
realpath: '/some/path' | ||
}, npa('file:/some/path'), {}), 'links must point at intended target') | ||
}, npa('file:/some/path'), null, {}), 'links must point at intended target') | ||
|
||
t.notOk(depValid({ | ||
isLink: true, | ||
realpath: '/some/other/path' | ||
}, 'file:/some/path', {}), 'links must point at intended target') | ||
}, 'file:/some/path', null, {}), 'links must point at intended target') | ||
|
||
t.notOk(depValid({ | ||
realpath: '/some/path' | ||
}, 'file:/some/path', {}), 'file:// must be a link') | ||
}, 'file:/some/path', null, {}), 'file:// must be a link') | ||
|
||
|
||
t.ok(depValid({ | ||
|
@@ -31,59 +37,59 @@ t.ok(depValid({ | |
package: { | ||
version: '1.2.3', | ||
}, | ||
}, 'git://host/repo#semver:1.x', {}), 'git url with semver range') | ||
}, 'git://host/repo#semver:1.x', null, {}), 'git url with semver range') | ||
|
||
t.ok(depValid({ | ||
name: 'foo', | ||
package: { | ||
name: 'bar', | ||
version: '1.2.3', | ||
}, | ||
}, 'npm:[email protected]', {}), 'alias is ok') | ||
}, 'npm:[email protected]', null, {}), 'alias is ok') | ||
|
||
t.ok(depValid({ | ||
resolved: 'https://registry/abbrev-1.1.1.tgz', | ||
package: {}, | ||
}, 'https://registry/abbrev-1.1.1.tgz', {}), 'remote url match') | ||
}, 'https://registry/abbrev-1.1.1.tgz', null, {}), 'remote url match') | ||
|
||
t.ok(depValid({ | ||
resolved: 'git+ssh://[email protected]/foo/bar', | ||
package: {}, | ||
}, 'git+ssh://[email protected]/foo/bar.git', {}), 'matching _from saveSpec') | ||
}, 'git+ssh://[email protected]/foo/bar.git', null, {}), 'matching _from saveSpec') | ||
|
||
t.notOk(depValid({ | ||
resolved: 'git+ssh://[email protected]/foo/bar', | ||
package: {}, | ||
}, 'git+ssh://[email protected]/bar/foo.git', {}), 'different repo') | ||
}, 'git+ssh://[email protected]/bar/foo.git', null, {}), 'different repo') | ||
|
||
t.notOk(depValid({ | ||
package: {}, | ||
}, 'git+ssh://[email protected]/bar/foo.git', {}), 'missing repo') | ||
}, 'git+ssh://[email protected]/bar/foo.git', null, {}), 'missing repo') | ||
|
||
t.ok(depValid({ | ||
resolved: '/path/to/tarball.tgz', | ||
}, '/path/to/tarball.tgz', {}), 'same tarball') | ||
}, '/path/to/tarball.tgz', null, {}), 'same tarball') | ||
|
||
t.notOk(depValid({ | ||
resolved: '/path/to/other/tarball.tgz', | ||
}, '/path/to/tarball.tgz', {}), 'different tarball') | ||
}, '/path/to/tarball.tgz', null, {}), 'different tarball') | ||
|
||
t.ok(depValid({ | ||
resolved: 'https://registry.npmjs.org/foo/foo-1.2.3.tgz', | ||
}, 'latest', {}), 'tagged registry version needs remote tarball') | ||
}, 'latest', null, {}), 'tagged registry version needs remote tarball') | ||
|
||
t.notOk(depValid({ | ||
resolved: 'git+https://registry.npmjs.org/foo/foo-1.2.3.git', | ||
}, 'latest', {}), 'tagged registry version needs remote tarball, not git') | ||
}, 'latest', null, {}), 'tagged registry version needs remote tarball, not git') | ||
|
||
t.notOk(depValid({}, 'latest', {}), | ||
t.notOk(depValid({}, 'latest', null, {}), | ||
'tagged registry version needs remote tarball resolution') | ||
|
||
t.test('unsupported dependency type', t => { | ||
const requestor = { errors: [] } | ||
const child = {name: 'kid'} | ||
const request = { type: 'not a type' } | ||
t.notOk(depValid(child, request, requestor)) | ||
t.notOk(depValid(child, request, null, requestor)) | ||
t.match(requestor, { | ||
errors: [{ | ||
message: 'Unsupported dependency type', | ||
|
@@ -98,7 +104,7 @@ t.test('invalid tag name', t => { | |
const requestor = { errors: [] } | ||
const child = { name: 'kid' } | ||
const request = '!!@#$%!#@$!' | ||
t.notOk(depValid(child, request, requestor)) | ||
t.notOk(depValid(child, request, null, requestor)) | ||
t.match(requestor, { | ||
errors: [{ | ||
message: 'Invalid tag name "!!@#$%!#@$!"', | ||
|
@@ -113,7 +119,7 @@ t.test('invalid request all together', t => { | |
const requestor = { errors: [] } | ||
const child = { name: 'kid' } | ||
const request = null | ||
t.notOk(depValid(child, request, requestor)) | ||
t.notOk(depValid(child, request, null, requestor)) | ||
t.match(requestor, { | ||
errors: [{ | ||
message: 'Invalid dependency specifier', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "@isaacs/testing-accept-dependencies-dep", | ||
"version": "1.0.0", | ||
"description": "a test of acceptDependencies", | ||
"dependencies": { | ||
"semver" : "6" | ||
}, | ||
"acceptDependencies": { | ||
"semver": "7" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...res/accept-dependencies/node_modules/@isaacs/testing-accept-dependencies-dep/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
test/fixtures/accept-dependencies/node_modules/semver/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@isaacs/testing-accept-dependencies", | ||
"version": "1.0.0", | ||
"description": "a test of acceptDependencies", | ||
"dependencies": { | ||
"@isaacs/testing-accept-dependencies-dep" : "1", | ||
"semver": "7" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "@isaacs/testing-accept-dependencies-with-newer", | ||
"version": "1.0.0", | ||
"description": "a test of acceptDependencies", | ||
"dependencies": { | ||
"@isaacs/testing-accept-dependencies-dep" : "1", | ||
"semver": "7" | ||
} | ||
} |