Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// TODO: try to cover with unit test the case when entry is no longer available in lockfile
// It is an edge that probably happens if the entry is removed during lockfile prune
if (depNode.requiresBuild && newWantedLockfile.packages![relativeDepPath]) {
newWantedLockfile.packages![relativeDepPath].requiresBuild = true
}
}))
let currentLockfile: Lockfile
const allImportersIncluded = R.equals(importerIds.sort(), Object.keys(newWantedLockfile.importers).sort())
if (
opts.makePartialCurrentLockfile ||
!allImportersIncluded
) {
const filteredCurrentLockfile = allImportersIncluded
? opts.currentLockfile
: filterLockfileByImporters(
opts.currentLockfile,
Object.keys(newWantedLockfile.importers)
.filter((importerId) => !importerIds.includes(importerId) && opts.currentLockfile.importers[importerId]),
{
...filterOpts,
failOnMissingDependencies: false,
},
)
const packages = filteredCurrentLockfile.packages || {}
if (newWantedLockfile.packages) {
for (const relDepPath in newWantedLockfile.packages) { // tslint:disable-line:forin
const depPath = dp.resolve(opts.registries, relDepPath)
if (depGraph[depPath]) {
packages[relDepPath] = newWantedLockfile.packages[relDepPath]
}
}
function getPkgsDepPathsOwnedOnlyByImporters (
importerIds: string[],
registries: Registries,
lockfile: Lockfile,
include: { [dependenciesField in DependenciesField]: boolean },
skipped: Set,
) {
const selected = filterLockfileByImporters(lockfile,
importerIds,
{
failOnMissingDependencies: false,
include,
registries,
skipped,
})
const other = filterLockfileByImporters(lockfile,
R.difference(Object.keys(lockfile.importers), importerIds),
{
failOnMissingDependencies: false,
include,
registries,
skipped,
})
const packagesOfSelectedOnly = R.pickAll(R.difference(Object.keys(selected.packages!), Object.keys(other.packages!)), selected.packages!) as PackageSnapshots
return getPkgsDepPaths(registries, packagesOfSelectedOnly)
}
virtualStoreDir: opts.virtualStoreDir,
wantedLockfile: newWantedLockfile,
})
stageLogger.debug({
prefix: opts.lockfileDir,
stage: 'importing_started',
})
const importerIds = importers.map(({ id }) => id)
const filterOpts = {
include: opts.include,
registries: opts.registries,
skipped: opts.skipped,
}
const newCurrentLockfile = filterLockfileByImporters(newWantedLockfile, importerIds, {
...filterOpts,
failOnMissingDependencies: true,
})
const newDepPaths = await linkNewPackages(
filterLockfileByImporters(opts.currentLockfile, importerIds, {
...filterOpts,
failOnMissingDependencies: false,
}),
newCurrentLockfile,
depGraph,
{
dryRun: opts.dryRun,
force: opts.force,
lockfileDir: opts.lockfileDir,
optional: opts.include.optionalDependencies,
registries: opts.registries,
prefix: opts.lockfileDir,
stage: 'importing_started',
})
const importerIds = importers.map(({ id }) => id)
const filterOpts = {
include: opts.include,
registries: opts.registries,
skipped: opts.skipped,
}
const newCurrentLockfile = filterLockfileByImporters(newWantedLockfile, importerIds, {
...filterOpts,
failOnMissingDependencies: true,
})
const newDepPaths = await linkNewPackages(
filterLockfileByImporters(opts.currentLockfile, importerIds, {
...filterOpts,
failOnMissingDependencies: false,
}),
newCurrentLockfile,
depGraph,
{
dryRun: opts.dryRun,
force: opts.force,
lockfileDir: opts.lockfileDir,
optional: opts.include.optionalDependencies,
registries: opts.registries,
storeController: opts.storeController,
virtualStoreDir: opts.virtualStoreDir,
},
)
function getPkgsDepPathsOwnedOnlyByImporters (
importerIds: string[],
registries: Registries,
lockfile: Lockfile,
include: { [dependenciesField in DependenciesField]: boolean },
skipped: Set,
) {
const selected = filterLockfileByImporters(lockfile,
importerIds,
{
failOnMissingDependencies: false,
include,
registries,
skipped,
})
const other = filterLockfileByImporters(lockfile,
R.difference(Object.keys(lockfile.importers), importerIds),
{
failOnMissingDependencies: false,
include,
registries,
skipped,
})
const packagesOfSelectedOnly = R.pickAll(R.difference(Object.keys(selected.packages!), Object.keys(other.packages!)), selected.packages!) as PackageSnapshots