-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [OSM-1122] improve workspaces parsing
- Loading branch information
Showing
16 changed files
with
358 additions
and
423 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,4 @@ | ||
import { parsePkgJson } from '../util'; | ||
import { | ||
PackageJsonBase, | ||
PnpmProjectParseOptions, | ||
PnpmWorkspaceArgs, | ||
} from '../types'; | ||
import { buildDepGraphPnpm } from './build-dep-graph-pnpm'; | ||
import { DepGraph } from '@snyk/dep-graph'; | ||
import { getPnpmLockfileParser } from './lockfile-parser/index'; | ||
import { PnpmLockfileParser } from './lockfile-parser/lockfile-parser'; | ||
import { NodeLockfileVersion } from '../../utils'; | ||
import { parsePnpmProject } from './parse-project'; | ||
import { parsePnpmWorkspace } from './parse-workspace'; | ||
|
||
export const parsePnpmProject = async ( | ||
pkgJsonContent: string, | ||
pnpmLockContent: string, | ||
options: PnpmProjectParseOptions, | ||
lockfileVersion?: NodeLockfileVersion, | ||
workspaceArgs?: PnpmWorkspaceArgs, | ||
): Promise<DepGraph> => { | ||
const { | ||
includeDevDeps, | ||
includeOptionalDeps, | ||
strictOutOfSync, | ||
pruneWithinTopLevelDeps, | ||
} = options; | ||
|
||
const pkgJson: PackageJsonBase = parsePkgJson(pkgJsonContent); | ||
|
||
const lockFileParser: PnpmLockfileParser = getPnpmLockfileParser( | ||
pnpmLockContent, | ||
lockfileVersion, | ||
workspaceArgs, | ||
); | ||
|
||
const depgraph = await buildDepGraphPnpm( | ||
lockFileParser, | ||
pkgJson, | ||
{ | ||
includeDevDeps, | ||
strictOutOfSync, | ||
includeOptionalDeps, | ||
pruneWithinTopLevelDeps, | ||
}, | ||
workspaceArgs, | ||
); | ||
|
||
return depgraph; | ||
}; | ||
export { parsePnpmProject, parsePnpmWorkspace }; |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { parsePkgJson } from '../util'; | ||
import { PackageJsonBase, PnpmProjectParseOptions } from '../types'; | ||
import { buildDepGraphPnpm } from './build-dep-graph-pnpm'; | ||
import { DepGraph } from '@snyk/dep-graph'; | ||
import { getPnpmLockfileParser } from './lockfile-parser/index'; | ||
import { NodeLockfileVersion } from '../../utils'; | ||
|
||
export const parsePnpmProject = async ( | ||
pkgJsonContent: string, | ||
pnpmLockContent: string, | ||
options: PnpmProjectParseOptions, | ||
lockfileVersion?: NodeLockfileVersion, | ||
): Promise<DepGraph> => { | ||
const { | ||
includeDevDeps, | ||
includeOptionalDeps, | ||
strictOutOfSync, | ||
pruneWithinTopLevelDeps, | ||
} = options; | ||
let importer = ''; | ||
|
||
const pkgJson: PackageJsonBase = parsePkgJson(pkgJsonContent); | ||
|
||
const lockFileParser = getPnpmLockfileParser( | ||
pnpmLockContent, | ||
lockfileVersion, | ||
); | ||
|
||
// Lockfile V9 simple project has the root importer | ||
if (lockFileParser.lockFileVersion.startsWith('9')) { | ||
importer = '.'; | ||
} | ||
|
||
const depgraph = await buildDepGraphPnpm( | ||
lockFileParser, | ||
pkgJson, | ||
{ | ||
includeDevDeps, | ||
strictOutOfSync, | ||
includeOptionalDeps, | ||
pruneWithinTopLevelDeps, | ||
}, | ||
importer, | ||
); | ||
|
||
return depgraph; | ||
}; |
Oops, something went wrong.