Skip to content

Commit

Permalink
Fix release script bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
elliette committed Jan 25, 2024
1 parent 29da608 commit 82c1201
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions tool/release.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ Future<int> runReset({
// Reset the dependency overrides for the package:
_updateOverrides(package, includeOverrides: true);

// If updating webdev, also reset the dwds override for test_common to prevent
// conflicts:
if (package == 'webdev') {
_updateOverrides('test_common', includeOverrides: true);
}

// Update the version strings in CHANGELOG and pubspec.yaml.
_updateVersionStrings(
package,
Expand Down Expand Up @@ -129,25 +123,19 @@ Future<int> runRelease({

// Update the pinned version of DWDS for webdev releases.
if (package == 'webdev') {
_logInfo('Updating pinned version of DWDS.');
await _updateDwdsPin('test_common');
final newVersion = await _updateDwdsPin('webdev');
_logInfo('Add pinned DWDS info to CHANGELOG.');
final changelog = File('../webdev/CHANGELOG.md');
_addNewLine(changelog,
newLine: '- Update `dwds` constraint to `${newVersion ?? 'TODO'}`.');
newLine: '- Update `dwds` constraint to `${newVersion ?? 'TODO'}`.',
insertAt: 2,
);
}

// Remove any dependency overrides for the package:
_logInfo('Removing dependency overrides for $package.');
_updateOverrides(package, includeOverrides: false);

// If updating webdev, also remove the dwds override for test_common to
// prevent conflicts:
if (package == 'webdev') {
_updateOverrides('test_common', includeOverrides: false);
}

// Run dart pub upgrade.
for (final packagePath in [
'../dwds',
Expand Down Expand Up @@ -245,8 +233,12 @@ void _updateVersionStrings(
void _addNewLine(
File file, {
required String newLine,
int insertAt = 0,
}) {
final newLines = [newLine, '', ...file.readAsLinesSync()];
final currentLines = file.readAsLinesSync();
final linesBefore = currentLines.sublist(0, insertAt);
final linesAfter = currentLines.sublist(insertAt);
final newLines = [...linesBefore, newLine, '', ...linesAfter];
final content = newLines.joinWithNewLine();
return file.writeAsStringSync(content);
}
Expand Down

0 comments on commit 82c1201

Please sign in to comment.