UNPKG

snyk-nodejs-lockfile-parser

Version:
35 lines 1.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parsePnpmProject = void 0; const util_1 = require("../util"); const build_dep_graph_pnpm_1 = require("./build-dep-graph-pnpm"); const index_1 = require("./lockfile-parser/index"); const parsePnpmProject = async (pkgJsonContent, pnpmLockContent, options, lockfileVersion) => { const { includeDevDeps, includePeerDeps, includeOptionalDeps, strictOutOfSync, pruneWithinTopLevelDeps, showNpmScope, } = options; let importer = ''; const pkgJson = (0, util_1.parsePkgJson)(pkgJsonContent); const lockFileParser = (0, index_1.getPnpmLockfileParser)(pnpmLockContent, lockfileVersion); // Lockfile V9 simple project has the root importer. // Some V6 lockfiles also embed the root importer as '.' inside the // top-level dependencies map (normaliseImporters moves it to importers). if (lockFileParser.rawPnpmLock.importers?.['.']) { importer = '.'; lockFileParser.workspaceArgs = { projectsVersionMap: { '.': { name: pkgJson.name, version: pkgJson.version }, }, isWorkspace: true, }; } const depgraph = await (0, build_dep_graph_pnpm_1.buildDepGraphPnpm)(lockFileParser, pkgJson, { includeDevDeps, strictOutOfSync, includePeerDeps, includeOptionalDeps, pruneWithinTopLevelDeps, showNpmScope, }, importer); return depgraph; }; exports.parsePnpmProject = parsePnpmProject; //# sourceMappingURL=parse-project.js.map