writeGeneratedSchema function
Writes a typed client and Dart schema snapshot after validating source.
output defaults to the source basename with an .orm.dart extension.
The snapshot uses the corresponding .snapshot.dart basename. Both are
derived files and are replaced when generation succeeds.
Implementation
Future<void> writeGeneratedSchema(String source, {String? output}) async {
output ??= p.setExtension(source, '.orm.dart');
final result = await generateSchema(source, outputPath: output);
final file = File(output);
await file.parent.create(recursive: true);
final snapshot = result.snapshotDart;
await file.writeAsString(result.dart);
await File(_schemaSnapshotPath(output)).writeAsString(snapshot);
}