Entrypoint class

The context surrounding the workspace pub is operating on.

Pub operates over a directed graph of dependencies that starts at a root "entrypoint" package. This is typically the package where the current working directory is located.

An entrypoint knows the workspaceRoot package it is associated with and is responsible for managing the package config (.dart_tool/package_config.json) and lock file (pubspec.lock) for it.

While entrypoints are typically applications, a pure library package may end up being used as an entrypoint while under development. Also, a single package may be used as an entrypoint in one context but not in another. For example, a package that contains a reusable library may not be the entrypoint when used by an app, but may be the entrypoint when you're running its tests.

Constructors

Entrypoint(String workingDir, SystemCache cache, {bool checkInCache = true})
An entrypoint for the workspace containing workingDir/
Entrypoint.global(Package package, LockFile? _lockFile, SystemCache cache, {SolveResult? solveResult})
Creates an entrypoint given package and lockfile objects. If a SolveResult is already created it can be passed as an optimization.

Properties

cache SystemCache
The system-wide cache which caches packages that need to be fetched over the network.
final
canFindWorkspaceRoot bool
True if we can find a pubspec.yaml to resolve in workingDir or any parent directory.
no setter
example Entrypoint?
Gets the Entrypoint package for the current working directory.
no setter
hashCode int
The hash code for this object.
no setterinherited
isCached bool
Whether this entrypoint exists within the package cache.
no setter
isCachedGlobal bool
Whether this is an entrypoint for a globally-activated package.
final
lockFile → LockFile
The lockfile for the entrypoint.
no setter
lockFilePath String
The path to the entrypoint workspace's lockfile.
no setter
packageConfig → PackageConfig
The .dart_tool/package_config.json package-config of this entrypoint.
no setter
packageConfigPath String
The path to the entrypoint's ".dart_tool/package_config.json" file relative to the current working directory .
getter/setter pair
packageGraph Future<PackageGraph>
The package graph for the application and all of its transitive dependencies.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
workingDir String
The directory where this entrypoint is created.
final
workPackage → Package
The "focus" package that the current command should act upon.
no setter
workspaceRoot → Package
The root package this entrypoint is associated with.
no setter

Methods

acquireDependencies(SolveType type, {Iterable<String>? unlock, bool dryRun = false, bool precompile = false, bool summaryOnly = false, bool enforceLockfile = false}) Future<void>
Gets all dependencies of the workspaceRoot package.
applyChanges(ChangeSet changeSet, bool dryRun) → void
Unless dryRun, loads pubspec.yaml of each package in changeSet and applies the changes to its (dev)-dependencies using yaml_edit to preserve textual structure.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pathOfSnapshot(Executable executable) String
The location of the snapshot of the dart program at path in package will be stored here.
precompileExecutable(Executable executable, {List<String> additionalSources = const [], String? nativeAssets}) Future<void>
Precompiles executable .dart file at path to a snapshot.
precompileExecutables() Future<void>
Precompiles all _builtExecutables.
tighten({List<String> packagesToUpgrade = const [], Map<Package, Map<PackageRange, PackageRange>> existingChanges = const {}, List<PackageId>? packageVersions}) Map<Package, Map<PackageRange, PackageRange>>
Returns a list of changes to constraints of workspace pubspecs updated to have their lower bound match the version in packageVersions (or this.lockFile).
toString() String
A string representation of this object.
inherited
withUpdatedRootPubspecs(Map<Package, Pubspec> updatedPubspecs) Entrypoint
Creates an entrypoint at the same location, but with each pubspec in updatedPubspecs replacing the with one for the corresponding package.
withWorkPubspec(Pubspec pubspec) Entrypoint
Creates an entrypoint at the same location, that will use pubspec for resolution of the workPackage.
writePackageConfigFile() Future<void>
Writes the .dart_tool/package_config.json file and workspace references to it.

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

ensureUpToDate(String dir, {required SystemCache cache, bool summaryOnly = true, bool onlyOutputWhenTerminal = true}) Future<({PackageConfig packageConfig, String rootDir})>
Does a fast-pass check to see if the resolution is up-to-date (_isUpToDate). If not, run a resolution with pub get semantics.