Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for (const name of Object.keys(dependencies)) {
if (bundled.has(name)) { continue; }
const { version: versionString, localPackage } = _resolveVersion(dependencies[name], searchPath);
const version = new semver.Range(versionString!);
if (!version) {
throw new Error(`Invalid semver expression for ${name}: ${versionString}`);
}
const pkg = _tryResolveAssembly(name, localPackage, searchPath);
LOG.debug(`Resolved dependency ${name} to ${pkg}`);
// eslint-disable-next-line no-await-in-loop
const assm = await loadAndValidateAssembly(pkg);
if (!version.intersects(new semver.Range(assm.version))) {
throw new Error(`Declared dependency on version ${versionString} of ${name}, but version ${assm.version} was found`);
}
packageVersions[assm.name] = packageVersions[assm.name] != null
? intersect(versionString!, packageVersions[assm.name])
: versionString!;
transitiveAssemblies[assm.name] = assm;
const pkgDir = path.dirname(pkg);
if (assm.dependencies) {
// eslint-disable-next-line no-await-in-loop
await _loadDependencies(assm.dependencies, pkgDir, transitiveAssemblies);
}
}
return packageVersions;
}
dependencies[depName] = deps[depName] as string;
}
}
logger.debug(`Recording update for ${JSON.stringify(depName)} to version ${updateVersion}.`);
if (allVersions[depName]) {
if (!semver.intersects(allVersions[depName], updateVersion)) {
throw new SchematicsException(
'Cannot update safely because packages have conflicting dependencies. Package '
+ `${depName} would need to match both versions "${updateVersion}" and `
+ `"${allVersions[depName]}, which are not compatible.`,
);
}
allVersions[depName] = semverIntersect.intersect(allVersions[depName], updateVersion);
} else {
allVersions[depName] = updateVersion;
}
return _getRecursiveVersions(
packageJson,
dependencies,
allVersions,
logger,
loose,
);
}),
);
mergeMap(([depName, depVersion]: [string, string]) => {
if (!packages[depName] || packages[depName] === depVersion) {
return EMPTY;
}
if (allVersions[depName] && semver.intersects(allVersions[depName], depVersion)) {
allVersions[depName] = semverIntersect.intersect(allVersions[depName], depVersion);
return EMPTY;
}
return _getNpmPackageJson(depName, logger).pipe(
map(json => ({ version: packages[depName], depName, depVersion, npmPackageJson: json })),
);
}),
mergeMap(({version, depName, depVersion, npmPackageJson}) => {