Skip to content

Commit

Permalink
feat: support for pnpm lockfile v9 (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
gemaxim committed May 10, 2024
1 parent 208c485 commit 2aec43f
Show file tree
Hide file tree
Showing 31 changed files with 837 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/lock-parser/build-dep-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export async function buildDepGraph(
switch (lockfileVersion) {
case NodeLockfileVersion.PnpmLockV5:
case NodeLockfileVersion.PnpmLockV6:
case NodeLockfileVersion.PnpmLockV9:
return await lockFileParser.parsePnpmProject(
manifestFileContents,
lockFileContents,
Expand Down
3 changes: 2 additions & 1 deletion lib/lock-parser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ export async function parse(
lockfileVersion === NodeLockfileVersion.NpmLockV2 ||
lockfileVersion === NodeLockfileVersion.NpmLockV3 ||
lockfileVersion === NodeLockfileVersion.PnpmLockV5 ||
lockfileVersion === NodeLockfileVersion.PnpmLockV6
lockfileVersion === NodeLockfileVersion.PnpmLockV6 ||
lockfileVersion === NodeLockfileVersion.PnpmLockV9
) {
return await buildDepGraph(
root,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"lodash.isempty": "^4.4.0",
"lodash.sortby": "^4.7.0",
"micromatch": "4.0.2",
"snyk-nodejs-lockfile-parser": "^1.53.3",
"snyk-nodejs-lockfile-parser": "^1.56.0",
"snyk-resolve-deps": "4.8.0"
},
"devDependencies": {
Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/pnpm/lock-v9/simple-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "one-dep",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"accepts": "1.3.7"
}
}
46 changes: 46 additions & 0 deletions test/fixtures/pnpm/lock-v9/simple-app/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions test/fixtures/pnpm/lock-v9/undefined-package-version/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "pnpm-shallow-goof",
"version": "0.0.1",
"description": "A vulnerable demo application",
"homepage": "https://snyk.io/",
"repository": {
"type": "git",
"url": "https://github.com/snyk-fixtures/pnpm-shallow-goof"
},
"dependencies": {
"a": "workspace:*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "a",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"node-uuid": "1.4.0",
"qs": "0.0.6"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "yarn-1-workspace-with-isolated-pkgs",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"react": "18.0.0"
},
"private": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "package-a",
"version": "1.0.0",
"dependencies": {
"ms": "2.1.2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "pkg-b",
"version": "1.0.0",
"dependencies": {
"accepts": "1.3.7"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// should get all subdirs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "pnpm-1-workspace-with-cross-ref",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"private": true,
"workspaces": ["packages/*"]
}

0 comments on commit 2aec43f

Please sign in to comment.