-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add pruning to yarn lock v1 dep graph builder
- Loading branch information
1 parent
c8b07a4
commit e79c464
Showing
102 changed files
with
1,105 additions
and
446 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,40 @@ | ||
import { buildDepGraphYarnLockV1Simple } from '.'; | ||
import { PackageJsonBase } from '../types'; | ||
import { PackageJsonBase, YarnLockV1ProjectParseOptions } from '../types'; | ||
import { parsePkgJson } from '../util'; | ||
import { buildDepGraphYarnLockV1SimpleCyclesPruned } from './build-depgraph-simple-pruned'; | ||
import { extractPkgsFromYarnLockV1 } from './extract-yarnlock-v1-pkgs'; | ||
import { ProjectParseOptions } from '../types'; | ||
|
||
export const parseYarnLockV1Project = async ( | ||
pkgJsonContent: string, | ||
yarnLockContent: string, | ||
options: ProjectParseOptions, | ||
options: YarnLockV1ProjectParseOptions, | ||
) => { | ||
const { includeDevDeps, includeOptionalDeps, pruneCycles, strictOutOfSync } = | ||
options; | ||
const { | ||
includeDevDeps, | ||
includeOptionalDeps, | ||
includePeerDeps, | ||
pruneLevel, | ||
strictOutOfSync, | ||
} = options; | ||
|
||
const pkgs = extractPkgsFromYarnLockV1(yarnLockContent); | ||
|
||
const pkgJson: PackageJsonBase = parsePkgJson(pkgJsonContent); | ||
|
||
const depGraph = pruneCycles | ||
? await buildDepGraphYarnLockV1SimpleCyclesPruned(pkgs, pkgJson, { | ||
includeDevDeps, | ||
strictOutOfSync, | ||
includeOptionalDeps, | ||
}) | ||
: await buildDepGraphYarnLockV1Simple(pkgs, pkgJson, { | ||
includeDevDeps, | ||
strictOutOfSync, | ||
includeOptionalDeps, | ||
}); | ||
const depGraph = | ||
pruneLevel === 'cycles' | ||
? await buildDepGraphYarnLockV1SimpleCyclesPruned(pkgs, pkgJson, { | ||
includeDevDeps, | ||
strictOutOfSync, | ||
includeOptionalDeps, | ||
}) | ||
: await buildDepGraphYarnLockV1Simple(pkgs, pkgJson, { | ||
includeDevDeps, | ||
includeOptionalDeps, | ||
includePeerDeps, | ||
strictOutOfSync, | ||
pruneWithinTopLevelDeps: pruneLevel === 'withinTopLevelDeps', | ||
}); | ||
|
||
return depGraph; | ||
}; |
6 changes: 6 additions & 0 deletions
6
test/jest/dep-graph-builders/fixtures/yarn-lock-v1/hand-rolled/empty/package.json
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,6 @@ | ||
{ | ||
"name": "empty", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT" | ||
} |
4 changes: 4 additions & 0 deletions
4
test/jest/dep-graph-builders/fixtures/yarn-lock-v1/hand-rolled/empty/yarn.lock
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,4 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
10 changes: 10 additions & 0 deletions
10
.../fixtures/yarn-lock-v1/hand-rolled/repeat-node-in-different-top-level-chains/package.json
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,10 @@ | ||
{ | ||
"name": "repeat-node-in-different-top-level-chains", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"a": "1.0.0", | ||
"d": "1.0.0" | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...ers/fixtures/yarn-lock-v1/hand-rolled/repeat-node-in-different-top-level-chains/yarn.lock
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,21 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
a@1.0.0: | ||
version "1.0.0" | ||
dependencies: | ||
b "1.0.0" | ||
|
||
b@1.0.0: | ||
version "1.0.0" | ||
dependencies: | ||
c "1.0.0" | ||
|
||
c@1.0.0: | ||
version "1.0.0" | ||
|
||
d@1.0.0: | ||
version "1.0.0" | ||
dependencies: | ||
b "1.0.0" |
9 changes: 9 additions & 0 deletions
9
...uilders/fixtures/yarn-lock-v1/hand-rolled/repeat-node-within-top-level-chain/package.json
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": "repeat-node-within-top-level-chain", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"a": "1.0.0" | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...h-builders/fixtures/yarn-lock-v1/hand-rolled/repeat-node-within-top-level-chain/yarn.lock
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,23 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
a@1.0.0: | ||
version "1.0.0" | ||
dependencies: | ||
b "1.0.0" | ||
d "1.0.0" | ||
|
||
b@1.0.0: | ||
version "1.0.0" | ||
dependencies: | ||
c "1.0.0" | ||
|
||
c@1.0.0: | ||
version "1.0.0" | ||
|
||
d@1.0.0: | ||
version "1.0.0" | ||
dependencies: | ||
b "1.0.0" | ||
|
9 changes: 9 additions & 0 deletions
9
test/jest/dep-graph-builders/fixtures/yarn-lock-v1/hand-rolled/simple-chain/package.json
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": "simple-chain", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"a": "1.0.0" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
test/jest/dep-graph-builders/fixtures/yarn-lock-v1/hand-rolled/simple-chain/yarn.lock
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 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
a@1.0.0: | ||
version "1.0.0" | ||
dependencies: | ||
b "1.0.0" | ||
|
||
b@1.0.0: | ||
version "1.0.0" |
9 changes: 9 additions & 0 deletions
9
...est/dep-graph-builders/fixtures/yarn-lock-v1/hand-rolled/simple-cyclic-chain/package.json
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": "simple-chain", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"a": "1.0.0" | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
test/jest/dep-graph-builders/fixtures/yarn-lock-v1/hand-rolled/simple-cyclic-chain/yarn.lock
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,13 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
a@1.0.0: | ||
version "1.0.0" | ||
dependencies: | ||
b "1.0.0" | ||
|
||
b@1.0.0: | ||
version "1.0.0" | ||
dependencies: | ||
a "1.0.0" |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.