snyk-nodejs-lockfile-parser
Version:
Generate a dep tree given a lockfile
31 lines • 1.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseYarnLockV1Project = void 0;
const _1 = require(".");
const pkgJson_1 = require("../../aliasesPreprocessors/pkgJson");
const util_1 = require("../util");
const build_depgraph_simple_pruned_1 = require("./build-depgraph-simple-pruned");
const extract_yarnlock_v1_pkgs_1 = require("./extract-yarnlock-v1-pkgs");
const parseYarnLockV1Project = async (pkgJsonContent, yarnLockContent, options) => {
const { includeDevDeps, includeOptionalDeps, includePeerDeps, pruneLevel, strictOutOfSync, honorAliases, showNpmScope, } = options;
const pkgs = (0, extract_yarnlock_v1_pkgs_1.extractPkgsFromYarnLockV1)(yarnLockContent);
const pkgJson = (0, util_1.parsePkgJson)(honorAliases ? (0, pkgJson_1.rewriteAliasesPkgJson)(pkgJsonContent) : pkgJsonContent);
const depGraph = pruneLevel === 'cycles'
? await (0, build_depgraph_simple_pruned_1.buildDepGraphYarnLockV1SimpleCyclesPruned)(pkgs, pkgJson, {
includeDevDeps,
strictOutOfSync,
includeOptionalDeps,
showNpmScope,
})
: await (0, _1.buildDepGraphYarnLockV1Simple)(pkgs, pkgJson, {
includeDevDeps,
includeOptionalDeps,
includePeerDeps,
strictOutOfSync,
pruneWithinTopLevelDeps: pruneLevel === 'withinTopLevelDeps',
showNpmScope,
});
return depGraph;
};
exports.parseYarnLockV1Project = parseYarnLockV1Project;
//# sourceMappingURL=simple.js.map