snyk-nodejs-lockfile-parser
Version:
Generate a dep tree given a lockfile
36 lines • 1.62 kB
JavaScript
;
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) => {
var _a;
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 ((_a = lockFileParser.rawPnpmLock.importers) === null || _a === void 0 ? void 0 : _a['.']) {
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