-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): improve yarn tarball detection (#18335)
- Loading branch information
Showing
2 changed files
with
222 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -616,6 +616,191 @@ describe('yarn LockFile utility', () => { | |
}); | ||
}); | ||
|
||
describe('auxiliary tagged version ranges', () => { | ||
beforeEach(() => { | ||
const fileSys = { | ||
'node_modules/@nrwl/nx-cloud/package.json': '{"version": "16.1.1"}', | ||
'node_modules/nx-cloud/package.json': '{"version": "16.1.1"}', | ||
'node_modules/postgres/package.json': '{"version": "3.2.4"}', | ||
}; | ||
vol.fromJSON(fileSys, '/root'); | ||
}); | ||
|
||
it('should parse tagged version range in combination with semver', () => { | ||
const lockFile = `# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
"@nrwl/[email protected]": | ||
version "16.1.1" | ||
resolved "http://localhost:4873/@nrwl%2fnx-cloud/-/nx-cloud-16.1.1.tgz#9e1ed2acff11ab0ae8a4c0c045d412034ac26be7" | ||
integrity sha512-iJIPP46+saFZK748FKU4u4YZH+Sv3ZvZPbMwGVMhwqhOYcrlO5aSa0lpilyoN8WuhooKNqcCfiqshx6V577fTg== | ||
dependencies: | ||
nx-cloud "16.1.1" | ||
[email protected], nx-cloud@latest: | ||
version "16.1.1" | ||
resolved "http://localhost:4873/nx-cloud/-/nx-cloud-16.1.1.tgz#103ae0f13f5eb05d6ddd6d9bfcafc56cf295a59a" | ||
integrity sha512-Rq7ynvkYzAJ67N3pDqU6cMqwvWP7WXJGP4EFjLxgUrRHNCccqDPggeAqePodfk3nZEUrZB8F5QBKZuuw1DR3oA== | ||
dependencies: | ||
"@nrwl/nx-cloud" "16.1.1" | ||
postgres@charsleysa/postgres#fix-errors-compiled: | ||
version "3.2.4" | ||
resolved "https://codeload.github.com/charsleysa/postgres/tar.gz/3b1a01b2da3e2fafb1a79006f838eff11a8de3cb" | ||
`; | ||
const packageJson: PackageJson = { | ||
name: '@my-ns/example', | ||
version: '0.0.1', | ||
type: 'commonjs', | ||
dependencies: { | ||
'nx-cloud': 'latest', | ||
postgres: 'charsleysa/postgres#fix-errors-compiled', | ||
}, | ||
}; | ||
|
||
const builder = new ProjectGraphBuilder(); | ||
parseYarnLockfile(lockFile, packageJson, builder); | ||
const graph = builder.getUpdatedProjectGraph(); | ||
expect(graph.externalNodes['npm:@nrwl/nx-cloud']).toMatchInlineSnapshot(` | ||
{ | ||
"data": { | ||
"hash": "sha512-iJIPP46+saFZK748FKU4u4YZH+Sv3ZvZPbMwGVMhwqhOYcrlO5aSa0lpilyoN8WuhooKNqcCfiqshx6V577fTg==", | ||
"packageName": "@nrwl/nx-cloud", | ||
"version": "16.1.1", | ||
}, | ||
"name": "npm:@nrwl/nx-cloud", | ||
"type": "npm", | ||
} | ||
`); | ||
expect(graph.externalNodes['npm:nx-cloud']).toMatchInlineSnapshot(` | ||
{ | ||
"data": { | ||
"hash": "sha512-Rq7ynvkYzAJ67N3pDqU6cMqwvWP7WXJGP4EFjLxgUrRHNCccqDPggeAqePodfk3nZEUrZB8F5QBKZuuw1DR3oA==", | ||
"packageName": "nx-cloud", | ||
"version": "16.1.1", | ||
}, | ||
"name": "npm:nx-cloud", | ||
"type": "npm", | ||
} | ||
`); | ||
expect(graph.externalNodes['npm:postgres']).toMatchInlineSnapshot(` | ||
{ | ||
"data": { | ||
"hash": "postgres|https://codeload.github.com/charsleysa/postgres/tar.gz/3b1a01b2da3e2fafb1a79006f838eff11a8de3cb", | ||
"packageName": "postgres", | ||
"version": "https://codeload.github.com/charsleysa/postgres/tar.gz/3b1a01b2da3e2fafb1a79006f838eff11a8de3cb", | ||
}, | ||
"name": "npm:postgres", | ||
"type": "npm", | ||
} | ||
`); | ||
}); | ||
|
||
it('should parse tagged version range in combination with semver in reverse order', () => { | ||
const lockFile = `# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
"@nrwl/[email protected]": | ||
version "16.1.1" | ||
resolved "http://localhost:4873/@nrwl%2fnx-cloud/-/nx-cloud-16.1.1.tgz#9e1ed2acff11ab0ae8a4c0c045d412034ac26be7" | ||
integrity sha512-iJIPP46+saFZK748FKU4u4YZH+Sv3ZvZPbMwGVMhwqhOYcrlO5aSa0lpilyoN8WuhooKNqcCfiqshx6V577fTg== | ||
dependencies: | ||
nx-cloud "16.1.1" | ||
nx-cloud@latest, [email protected]: | ||
version "16.1.1" | ||
resolved "http://localhost:4873/nx-cloud/-/nx-cloud-16.1.1.tgz#103ae0f13f5eb05d6ddd6d9bfcafc56cf295a59a" | ||
integrity sha512-Rq7ynvkYzAJ67N3pDqU6cMqwvWP7WXJGP4EFjLxgUrRHNCccqDPggeAqePodfk3nZEUrZB8F5QBKZuuw1DR3oA== | ||
dependencies: | ||
"@nrwl/nx-cloud" "16.1.1" | ||
postgres@charsleysa/postgres#fix-errors-compiled: | ||
version "3.2.4" | ||
resolved "https://codeload.github.com/charsleysa/postgres/tar.gz/3b1a01b2da3e2fafb1a79006f838eff11a8de3cb" | ||
`; | ||
const packageJson: PackageJson = { | ||
name: '@my-ns/example', | ||
version: '0.0.1', | ||
type: 'commonjs', | ||
dependencies: { | ||
'nx-cloud': 'latest', | ||
postgres: 'charsleysa/postgres#fix-errors-compiled', | ||
}, | ||
}; | ||
|
||
const builder = new ProjectGraphBuilder(); | ||
parseYarnLockfile(lockFile, packageJson, builder); | ||
const graph = builder.getUpdatedProjectGraph(); | ||
expect(graph.externalNodes['npm:@nrwl/nx-cloud']).toMatchInlineSnapshot(` | ||
{ | ||
"data": { | ||
"hash": "sha512-iJIPP46+saFZK748FKU4u4YZH+Sv3ZvZPbMwGVMhwqhOYcrlO5aSa0lpilyoN8WuhooKNqcCfiqshx6V577fTg==", | ||
"packageName": "@nrwl/nx-cloud", | ||
"version": "16.1.1", | ||
}, | ||
"name": "npm:@nrwl/nx-cloud", | ||
"type": "npm", | ||
} | ||
`); | ||
expect(graph.externalNodes['npm:nx-cloud']).toMatchInlineSnapshot(` | ||
{ | ||
"data": { | ||
"hash": "sha512-Rq7ynvkYzAJ67N3pDqU6cMqwvWP7WXJGP4EFjLxgUrRHNCccqDPggeAqePodfk3nZEUrZB8F5QBKZuuw1DR3oA==", | ||
"packageName": "nx-cloud", | ||
"version": "16.1.1", | ||
}, | ||
"name": "npm:nx-cloud", | ||
"type": "npm", | ||
} | ||
`); | ||
expect(graph.externalNodes['npm:postgres']).toMatchInlineSnapshot(` | ||
{ | ||
"data": { | ||
"hash": "postgres|https://codeload.github.com/charsleysa/postgres/tar.gz/3b1a01b2da3e2fafb1a79006f838eff11a8de3cb", | ||
"packageName": "postgres", | ||
"version": "https://codeload.github.com/charsleysa/postgres/tar.gz/3b1a01b2da3e2fafb1a79006f838eff11a8de3cb", | ||
}, | ||
"name": "npm:postgres", | ||
"type": "npm", | ||
} | ||
`); | ||
}); | ||
|
||
it('should parse tagged version range', () => { | ||
const lockFile = `# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
nx-cloud@latest: | ||
version "16.1.1" | ||
resolved "http://localhost:4873/nx-cloud/-/nx-cloud-16.1.1.tgz#103ae0f13f5eb05d6ddd6d9bfcafc56cf295a59a" | ||
integrity sha512-Rq7ynvkYzAJ67N3pDqU6cMqwvWP7WXJGP4EFjLxgUrRHNCccqDPggeAqePodfk3nZEUrZB8F5QBKZuuw1DR3oA== | ||
`; | ||
const packageJson: PackageJson = { | ||
name: '@my-ns/example', | ||
version: '0.0.1', | ||
type: 'commonjs', | ||
dependencies: { | ||
'nx-cloud': 'latest', | ||
}, | ||
}; | ||
|
||
const builder = new ProjectGraphBuilder(); | ||
parseYarnLockfile(lockFile, packageJson, builder); | ||
const graph = builder.getUpdatedProjectGraph(); | ||
expect(graph.externalNodes['npm:nx-cloud']).toMatchInlineSnapshot(` | ||
{ | ||
"data": { | ||
"hash": "sha512-Rq7ynvkYzAJ67N3pDqU6cMqwvWP7WXJGP4EFjLxgUrRHNCccqDPggeAqePodfk3nZEUrZB8F5QBKZuuw1DR3oA==", | ||
"packageName": "nx-cloud", | ||
"version": "16.1.1", | ||
}, | ||
"name": "npm:nx-cloud", | ||
"type": "npm", | ||
} | ||
`); | ||
}); | ||
}); | ||
|
||
describe('auxiliary packages PnP', () => { | ||
it('should parse yarn berry pnp', () => { | ||
const berryLockFile = require(joinPathFragments( | ||
|
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
423a68b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
nx-dev – ./
nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx.dev