Skip to content

Commit

Permalink
Update changelog in patch_output.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexios80 committed Apr 30, 2024
1 parent 2621e72 commit bc9c3a6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
25 changes: 22 additions & 3 deletions vrchat_dart/tool/patch_output.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@ import 'package:fixer/fixer.dart';

void main() async {
final spec = jsonDecode(File('build/spec.json').readAsStringSync());
final version = spec['info']['version'] as String;

print('Patching pubspec...');
patchPubspec(spec);
patchPubspec(version);
print('Pubspec patched!');

print('Patching changelog...');
patchChangelog(version);
print('Changelog patched!');

print('Patching lib/src/model...');
patchModel();
print('Model patched!');
Expand All @@ -23,8 +28,7 @@ void main() async {
print('Analysis issues patched!');
}

void patchPubspec(Map<String, dynamic> spec) {
final version = spec['info']['version'] as String;
void patchPubspec(String version) {
final pubspec = File('../vrchat_dart_generated/pubspec.yaml');
final content = pubspec.readAsStringSync();
final newContent = content.replaceFirst(
Expand All @@ -34,6 +38,21 @@ void patchPubspec(Map<String, dynamic> spec) {
pubspec.writeAsStringSync(newContent);
}

void patchChangelog(String version) {
final changelog = File('../vrchat_dart_generated/CHANGELOG.md');
final content = changelog.readAsStringSync();

/// Don't add duplicate version to changelog
if (content.contains('## $version')) return;

final newContent = '''
## $version
- Updated to match spec
$content''';
changelog.writeAsStringSync(newContent);
}

final _enumToString = r'''
@override
String toString() => this.name;
Expand Down
3 changes: 3 additions & 0 deletions vrchat_dart_generated/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.17.2
- Updated to match spec

## 1.17.0
- Updated to match spec

Expand Down

0 comments on commit bc9c3a6

Please sign in to comment.