writePubspecVersion function
Writes the version field to a pubspec.yaml file, preserving all other
content (including comments and formatting).
Implementation
Future<void> writePubspecVersion(String filePath, String version) async {
final file = File(filePath);
await file.writeAsString(
renderPubspecVersion(await file.readAsString(), version),
);
}