snyk-nodejs-lockfile-parser
Version:
Generate a dep tree given a lockfile
32 lines • 1.65 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseYarnLockV1Project = void 0;
const _1 = require(".");
const pkgJson_1 = require("../../aliasesPreprocessors/pkgJson");
const yarn_lock_v1_1 = require("../../aliasesPreprocessors/yarn-lock-v1");
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, } = options;
const pkgs = (0, extract_yarnlock_v1_pkgs_1.extractPkgsFromYarnLockV1)(honorAliases
? (0, yarn_lock_v1_1.rewriteAliasesInYarnLockV1)(yarnLockContent)
: 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,
})
: await (0, _1.buildDepGraphYarnLockV1Simple)(pkgs, pkgJson, {
includeDevDeps,
includeOptionalDeps,
includePeerDeps,
strictOutOfSync,
pruneWithinTopLevelDeps: pruneLevel === 'withinTopLevelDeps',
});
return depGraph;
};
exports.parseYarnLockV1Project = parseYarnLockV1Project;
//# sourceMappingURL=simple.js.map
;