InstallContext class

Dependency-injection container handed to every install operation in the PluginInstaller DSL.

Composes (never inherits) ArtisanContext so command-side concerns (input / output / VM client) stay reachable while the installer adds its own four-way seam: VirtualFs for filesystem access, PromptDriver for interactive prompts, StubDriver for template resolution, and a clock callback for time-sensitive metadata (record timestamps, dry-run headers).

Two named constructors target the two consumption modes:

Every field is final + non-nullable so install operations can read the context without null checks at every call site.

Usage

// production
final ctx = InstallContext.real(artisanCtx);
final installer = PluginInstaller(ctx);

// tests
final ctx = InstallContext.test(
  fs: InMemoryFs(),
  prompt: FakePromptDriver(['y']),
  stubs: FakeStubDriver({'config': '...'}),
  clock: () => DateTime.utc(2025, 1, 1),
);

Constructors

InstallContext.real(ArtisanContext artisanContext, {String? projectRoot})
Wires the production stack: RealFs for filesystem access, RealPromptDriver for stdin prompts, RealStubDriver for asset resolution, and DateTime.now as the clock source.
InstallContext.test({required VirtualFs fs, required PromptDriver prompt, required StubDriver stubs, DateTime clock()?, ArtisanInput? input, ArtisanOutput? output, String projectRoot = '/test'})
Wires a fully injectable InstallContext for tests.
factory

Properties

artisanContext ArtisanContext
The wrapping command context (input / output / optional VM client). Composed, not inherited, so install ops can reach the command surface without polluting the InstallContext API.
final
clock DateTime Function()
Clock callback used for any time-stamped metadata (e.g. the installedAt field in .artisan/installed/<plugin>.json). Injectable so tests can pin the time to a fixed value.
final
fs VirtualFs
Filesystem seam. Production wiring uses RealFs; tests typically pass an InMemoryFs.
final
hashCode int
The hash code for this object.
no setterinherited
projectRoot String
Absolute path to the consumer project root. Install ops resolve target paths relative to this directory.
final
prompt PromptDriver
Interactive-prompt seam. Wraps the static Prompt helper in production and a recording fake in tests.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stubs StubDriver
Stub-template seam. Wraps the static StubLoader helper in production and a fixture-backed fake in tests.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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