forDirectory static method
Implementation
static Future<VizRoot> forDirectory(
Service service, {
bool flagOutdated = false,
Iterable<String>? ignorePackages,
bool directDependenciesOnly = false,
bool productionDependenciesOnly = false,
}) async {
final rootPubspec = service.rootPubspec();
final packages = await service.getReferencedPackages(
flagOutdated,
directDependenciesOnly,
productionDependenciesOnly,
);
final value = VizRoot._(rootPubspec.name, packages).._update();
if (flagOutdated) {
for (var dep in _allDeps(value, ignorePackages)) {
assert(dep.includesLatest == null);
final package = packages[dep.name];
if (package != null &&
package.latestVersion != null &&
dep.versionConstraint != VersionConstraint.empty) {
var allowsLatest =
dep.versionConstraint.allows(package.latestVersion!);
if (!allowsLatest) {
// it could be that the versionConstraint is actually *ahead* of
// latest – with a pre-release version
// TODO: get rid of the `as` here – this is weird!
final constraintAsRange = dep.versionConstraint as VersionRange;
if (package.latestVersion!.compareTo(constraintAsRange) < 0) {
allowsLatest = true;
}
}
dep.includesLatest = allowsLatest;
}
}
}
return value;
}