Installer class
The steps of a <package>:install command, so dox add <package>
sets up the app.
Every step is safe to run twice: it never overwrites a file and never adds a key twice. Each step adds one line to the summary that printSummary prints at the end.
Installer installer = Installer();
await installer.addDependency('dox_migration');
installer.writeFile('lib/config/database.dart', source);
installer.addEnv('DB_CONNECTION', 'sqlite');
await installer.buildRunner();
installer.printSummary(<String>['Run `dox migrate`.']);
Constructors
- Installer({Directory? root, ProcessRunner? runner})
-
rootis the app folder, the current folder by default
Properties
- appName → String
-
the
name:of the app pubspec.yaml, forpackage:<app>/...importsno setter - hashCode → int
-
The hash code for this object.
no setterinherited
-
lines
→ List<
String> -
the lines that printSummary prints, read only. Add one with note.
no setter
- ok ↔ bool
-
false when a step failed (a
dartcommand or a missing file)getter/setter pair - root → Directory
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addDependency(
String package, {bool dev = false}) → Future< bool> -
dart pub add [--dev] <package>when the app does not have it yet -
addEnv(
String key, String value) → void -
add
KEY=valueto.env.exampleand.envwhen the key is not in the file. A key that is there is never changed. A file that is not there is skipped. -
addEnvGetter(
String getter) → void -
add
getter(likeString get dbName => 'db/dox.sqlite';, with optional///lines above it) to theAppEnvclass oflib/config/env.dart, when the class has no member with the same name. Run buildRunner after it. -
buildRunner(
) → Future< bool> -
dart run build_runner build, to make the generated files again -
hasDependency(
String package) → bool -
true when
packageis independenciesordev_dependenciesof the app pubspec.yaml -
makeFolder(
String path) → void -
make the folder
pathwhen it is not there -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
note(
String line) → void -
add a line to the summary, for a step that is not in this class.
Start it with
created,added,skippedorfailedand two spaces, like the other lines. -
printSummary(
List< String> nextSteps) → void -
print what was done and the
nextSteps. Sets exit code 1 when a step failed. -
toString(
) → String -
A string representation of this object.
inherited
-
writeFile(
String path, String content) → bool -
write
contenttopath(relative to the app folder) only when the file is not there. Returns true when the file was made.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited