PluginsRegistryFile class

Reads and writes the .artisan/plugins.json registry file through a VirtualFs abstraction so the class is fully testable without touching the host filesystem.

Schema: {"version": 1, "plugins": [...]}

Atomic write

write follows the same .tmp + rename pattern used by InstallTransaction: content is written to <projectRoot>/.artisan/plugins.json.tmp first and then renamed over the target. On POSIX systems this rename is atomic, so readers never observe a partial write.

Idempotent mutations

addPlugin replaces any existing entry with the same PluginEntry.name instead of appending a duplicate. removePlugin is a no-op when the name is absent.

Version guard

read throws FormatException when the stored version field exceeds 1 so old tooling fails loudly rather than silently misinterpreting a newer schema.

Usage

final rf = PluginsRegistryFile(RealFs(), projectRoot);
await rf.addPlugin(PluginEntry(
  name: 'firebase_messaging',
  providerImport: 'package:magic_firebase/src/provider.dart',
  providerClass: 'FirebaseProvider',
  registeredAt: DateTime.now().toUtc().toIso8601String(),
));

Constructors

PluginsRegistryFile(VirtualFs _fs, String _projectRoot)
Creates a PluginsRegistryFile bound to the given VirtualFs and projectRoot.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addPlugin(PluginEntry entry) Future<void>
Adds entry to the registry.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read() Future<PluginsRegistry>
Reads the registry from disk.
removePlugin(String name) Future<void>
Removes the plugin identified by name from the registry.
toString() String
A string representation of this object.
inherited
write(PluginsRegistry registry) Future<void>
Atomically writes registry to disk using a .tmp + rename strategy.

Operators

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