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:
- InstallContext.real wires production drivers (RealFs /
RealPromptDriver / RealStubDriver /
() => DateTime.now()) and resolves projectRoot via FileHelper.findProjectRoot when not supplied. - InstallContext.test accepts every dependency explicitly so tests can run the full installer lifecycle in-memory.
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.nowas 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
installedAtfield 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
StubLoaderhelper 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