@@ -130,8 +130,12 @@ Future<int> runRelease({
130
130
// Update the pinned version of DWDS for webdev releases.
131
131
if (package == 'webdev' ) {
132
132
_logInfo ('Updating pinned version of DWDS.' );
133
- await _updateDwdsPin ('webdev' );
134
133
await _updateDwdsPin ('test_common' );
134
+ final newVersion = await _updateDwdsPin ('webdev' );
135
+ _logInfo ('Add pinned DWDS info to CHANGELOG.' );
136
+ final changelog = File ('../webdev/CHANGELOG.md' );
137
+ _addNewLine (changelog,
138
+ newLine: '- Update `dwds` constraint to `${newVersion ?? 'TODO' }`.' );
135
139
}
136
140
137
141
// Remove any dependency overrides for the package:
@@ -229,12 +233,7 @@ void _updateVersionStrings(
229
233
final pubspec = File ('../$package /pubspec.yaml' );
230
234
final changelog = File ('../$package /CHANGELOG.md' );
231
235
if (isReset) {
232
- final wasReplaced = _replaceInFile (
233
- changelog,
234
- query: currentVersion,
235
- replaceWith: nextVersion,
236
- );
237
- if (! wasReplaced) _addNewLine (changelog, newLine: '## $nextVersion ' );
236
+ _addNewLine (changelog, newLine: '## $nextVersion ' );
238
237
_replaceInFile (pubspec, query: currentVersion, replaceWith: nextVersion);
239
238
} else {
240
239
for (final file in [pubspec, changelog]) {
@@ -296,7 +295,8 @@ String _removeWip(String wipVersion) {
296
295
return wipVersion.split ('-wip' ).first;
297
296
}
298
297
299
- Future <void > _updateDwdsPin (String package) async {
298
+ /// Returns the new pinned DWDS version on success.
299
+ Future <String ?> _updateDwdsPin (String package) async {
300
300
final pubOutdatedProcess = await Process .run (
301
301
'dart' ,
302
302
[
@@ -307,21 +307,31 @@ Future<void> _updateDwdsPin(String package) async {
307
307
workingDirectory: '../$package ' ,
308
308
);
309
309
final lines = pubOutdatedProcess.stdout.split ('\n ' ) as List <String >;
310
+ String ? nextDwdsVersion;
311
+ String ? currentDwdsVersion;
310
312
for (final line in lines) {
311
313
if (line.trim ().startsWith ('dwds' )) {
312
314
final segments =
313
315
line.trim ().split (' ' ).where ((segment) => segment != ' ' );
314
- final nextVersion = segments.last;
315
- final currentVersion =
316
+ nextDwdsVersion = segments.last;
317
+ currentDwdsVersion =
316
318
segments.lastWhere ((segment) => segment.startsWith ('*' )).substring (1 );
317
- _logInfo ('Changing DWDS pin from $currentVersion to $nextVersion ' );
318
- _replaceInFile (
319
- File ('../$package /pubspec.yaml' ),
320
- query: currentVersion,
321
- replaceWith: nextVersion,
322
- );
319
+ break ;
323
320
}
324
321
}
322
+ final next = nextDwdsVersion ?? '' ;
323
+ final current = currentDwdsVersion ?? '' ;
324
+ if (next.isNotEmpty && current.isNotEmpty) {
325
+ _logInfo ('Changing DWDS pin from $current to $next ' );
326
+ _replaceInFile (
327
+ File ('../$package /pubspec.yaml' ),
328
+ query: current,
329
+ replaceWith: next,
330
+ );
331
+ return nextDwdsVersion;
332
+ }
333
+ _logWarning ('Unable to determine DWDS version to pin.' );
334
+ return null ;
325
335
}
326
336
327
337
void _logInfo (String message) {
0 commit comments