Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const importersToLink = await Promise.all(importersToResolve.map(async (importer, index) => {
const resolvedImporter = resolvedImporters[importer.id]
let newPkg: ImporterManifest | undefined = importer.manifest
if (importer.updatePackageManifest) {
newPkg = await updateImporterManifest(importersToResolve[index], {
directDependencies: resolvedImporter.directDependencies,
preserveWorkspaceProtocol: opts.preserveWorkspaceProtocol,
saveWorkspaceProtocol: opts.saveWorkspaceProtocol,
})
} else {
packageManifestLogger.debug({
prefix: importer.rootDir,
updated: importer.manifest,
})
}
if (newPkg) {
const lockfileImporter = ctx.wantedLockfile.importers[importer.id]
ctx.wantedLockfile.importers[importer.id] = addDirectDependenciesToLockfile(
newPkg,
lockfileImporter,
resolvedImporter.linkedDependencies,
resolvedImporter.directDependencies,
ctx.registries,
)
}
rootModulesDir,
shamefullyHoist: sHoist,
skipped,
storeDir,
virtualStoreDir,
...await readLockfileFile({
force: opts.force,
forceSharedLockfile: opts.forceSharedLockfile,
importers: [{ id: importerId, rootDir: opts.dir }],
lockfileDir: opts.lockfileDir,
registry: opts.registries.default,
useLockfile: opts.useLockfile,
virtualStoreDir,
}),
}
packageManifestLogger.debug({
initial: manifest,
prefix: opts.dir,
})
return ctx
}
delete packageManifest[deptype]![packageSpec.alias]
}
})
if (packageSpec.peer === true) {
packageManifest.peerDependencies = packageManifest.peerDependencies || {}
packageManifest.peerDependencies[packageSpec.alias] = spec
}
}
} else if (packageSpec.pref) {
const usedDepType = guessDependencyType(packageSpec.alias, packageManifest as ImporterManifest) || 'dependencies'
packageManifest[usedDepType] = packageManifest[usedDepType] || {}
packageManifest[usedDepType]![packageSpec.alias] = packageSpec.pref
}
})
packageManifestLogger.debug({
prefix,
updated: packageManifest,
})
return packageManifest as ImporterManifest
}
importers.forEach((importer) => {
packageManifestLogger.debug({
initial: importer.manifest,
prefix: importer.rootDir,
})
})
if (opts.hooks?.readPackage) {
} else {
DEPENDENCIES_FIELDS
.filter((depField) => packageManifest[depField])
.forEach((depField) => {
removedPackages.forEach((dependency) => {
delete packageManifest[depField]![dependency]
})
})
}
if (packageManifest.peerDependencies) {
for (const removedDependency of removedPackages) {
delete packageManifest.peerDependencies[removedDependency]
}
}
packageManifestLogger.debug({
prefix: opts.prefix,
updated: packageManifest,
})
return packageManifest
}