Skip to content

Commit 211b4fa

Browse files
authored
command pub check-resolution-up-to-date (#4655)
1 parent eb0952e commit 211b4fa

File tree

5 files changed

+411
-249
lines changed

5 files changed

+411
-249
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
import '../command.dart';
8+
import '../command_runner.dart';
9+
import '../entrypoint.dart';
10+
import '../log.dart' as log;
11+
import '../utils.dart';
12+
13+
class CheckResolutionUpToDateCommand extends PubCommand {
14+
@override
15+
String get name => 'check-resolution-up-to-date';
16+
17+
@override
18+
bool get hidden => true;
19+
20+
@override
21+
String get description => '''
22+
Do a fast timestamp-based check to see resolution is up-to-date and internally
23+
consistent.
24+
25+
If timestamps are correctly ordered, exit 0, and do not check the external sources for
26+
newer versions.
27+
Otherwise exit non-zero.
28+
''';
29+
30+
@override
31+
String get argumentsDescription => '';
32+
33+
CheckResolutionUpToDateCommand();
34+
35+
@override
36+
Future<void> runProtected() async {
37+
final result = Entrypoint.isResolutionUpToDate(directory, cache);
38+
if (result == null) {
39+
fail('Resolution needs updating. Run `$topLevelProgram pub get`');
40+
} else {
41+
log.message('Resolution is up-to-date');
42+
}
43+
}
44+
}

lib/src/command_runner.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import 'command.dart' show PubTopLevel, lineLength;
1313
import 'command/add.dart';
1414
import 'command/bump.dart';
1515
import 'command/cache.dart';
16+
import 'command/check_resolution_up_to_date.dart';
1617
import 'command/deps.dart';
1718
import 'command/downgrade.dart';
1819
import 'command/get.dart';
@@ -151,6 +152,7 @@ class PubCommandRunner extends CommandRunner<int> implements PubTopLevel {
151152
addCommand(OutdatedCommand());
152153
addCommand(RemoveCommand());
153154
addCommand(RunCommand());
155+
addCommand(CheckResolutionUpToDateCommand());
154156
addCommand(UpgradeCommand());
155157
addCommand(UnpackCommand());
156158
addCommand(UploaderCommand());

0 commit comments

Comments
 (0)