mirror of
https://github.com/flutter/flutter
synced 2024-08-24 18:36:03 +00:00
Remove message about pub cache
that is not actionable (#143357)
... and neither the pub nor tools team think it's important. Fixes https://github.com/flutter/flutter/issues/140628.
This commit is contained in:
parent
2adbc2b8ce
commit
66367dd888
|
@ -609,7 +609,6 @@ class _DefaultPub implements Pub {
|
|||
/// We only want to inform about existing caches on first run of a freshly
|
||||
/// downloaded Flutter SDK. Therefore it is conditioned on the existence
|
||||
/// of the .pub-preload-cache dir.
|
||||
_informAboutExistingCaches();
|
||||
final Iterable<String> cacheFiles =
|
||||
preloadCacheDir
|
||||
.listSync()
|
||||
|
@ -620,50 +619,6 @@ class _DefaultPub implements Pub {
|
|||
}
|
||||
}
|
||||
|
||||
/// Issues a log message if there is an existing pub cache and or an existing
|
||||
/// Dart Analysis Server cache.
|
||||
void _informAboutExistingCaches() {
|
||||
final String? pubCachePath = _pubCacheDefaultLocation();
|
||||
if (pubCachePath != null) {
|
||||
final Directory pubCacheDirectory = _fileSystem.directory(pubCachePath);
|
||||
if (pubCacheDirectory.existsSync()) {
|
||||
_logger.printStatus('''
|
||||
Found an existing Pub cache at $pubCachePath.
|
||||
It can be repaired by running `dart pub cache repair`.
|
||||
It can be reset by running `dart pub cache clean`.''');
|
||||
}
|
||||
}
|
||||
final String? home = _platform.environment['HOME'];
|
||||
if (home != null) {
|
||||
final String dartServerCachePath = _fileSystem.path.join(home, '.dartServer');
|
||||
if (_fileSystem.directory(dartServerCachePath).existsSync()) {
|
||||
_logger.printStatus('''
|
||||
Found an existing Dart Analysis Server cache at $dartServerCachePath.
|
||||
It can be reset by deleting $dartServerCachePath.''');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The default location of the Pub cache if the PUB_CACHE environment variable
|
||||
/// is not set.
|
||||
///
|
||||
/// Returns null if the appropriate environment variables are unset.
|
||||
String? _pubCacheDefaultLocation () {
|
||||
if (_platform.isWindows) {
|
||||
final String? localAppData = _platform.environment['LOCALAPPDATA'];
|
||||
if (localAppData == null) {
|
||||
return null;
|
||||
}
|
||||
return _fileSystem.path.join(localAppData, 'Pub', 'Cache');
|
||||
} else {
|
||||
final String? home = _platform.environment['HOME'];
|
||||
if (home == null) {
|
||||
return null;
|
||||
}
|
||||
return _fileSystem.path.join(home, '.pub-cache');
|
||||
}
|
||||
}
|
||||
|
||||
/// The full environment used when running pub.
|
||||
///
|
||||
/// [context] provides extra information to package server requests to
|
||||
|
|
|
@ -866,98 +866,11 @@ exit code: 66
|
|||
await pub.get(
|
||||
project: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
|
||||
context: PubContext.flutterTests);
|
||||
expect(logger.statusText, isNot(contains('Found an existing Pub cache')));
|
||||
expect(logger.statusText,
|
||||
isNot(contains('Found an existing Dart Analysis Server cache')));
|
||||
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
expect(preloadCache.existsSync(), false);
|
||||
});
|
||||
|
||||
testWithoutContext('Notifies about existing caches, on first run only',
|
||||
() async {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
final Directory preloadCache =
|
||||
fileSystem.currentDirectory.childDirectory('.pub-preload-cache');
|
||||
preloadCache.childFile('a.tar.gz').createSync(recursive: true);
|
||||
fileSystem.currentDirectory.childFile('version').createSync();
|
||||
fileSystem.directory('/global/.pub-cache').createSync(recursive: true);
|
||||
fileSystem.directory('/global/.dartServer').createSync(recursive: true);
|
||||
|
||||
const FakeCommand dartPreloadCommand = FakeCommand(
|
||||
command: <String>[
|
||||
'bin/cache/dart-sdk/bin/dart',
|
||||
'pub',
|
||||
'--suppress-analytics',
|
||||
'cache',
|
||||
'preload',
|
||||
'.pub-preload-cache/a.tar.gz',
|
||||
],
|
||||
);
|
||||
final FakeCommand dartPubGetCommand = FakeCommand(
|
||||
command: const <String>[
|
||||
'bin/cache/dart-sdk/bin/dart',
|
||||
'pub',
|
||||
'--suppress-analytics',
|
||||
'--directory',
|
||||
'.',
|
||||
'get',
|
||||
'--example',
|
||||
],
|
||||
environment: const <String, String>{
|
||||
'FLUTTER_ROOT': '',
|
||||
'PUB_ENVIRONMENT': 'flutter_cli:flutter_tests',
|
||||
},
|
||||
onRun: (_) {
|
||||
fileSystem.currentDirectory
|
||||
.childDirectory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
.createSync(recursive: true);
|
||||
});
|
||||
|
||||
final FakeProcessManager processManager =
|
||||
FakeProcessManager.list(<FakeCommand>[
|
||||
dartPreloadCommand,
|
||||
dartPubGetCommand,
|
||||
dartPubGetCommand,
|
||||
]);
|
||||
|
||||
final Platform platform =
|
||||
FakePlatform(environment: <String, String>{'HOME': '/global'});
|
||||
final BufferLogger logger = BufferLogger.test();
|
||||
final Pub pub = Pub.test(
|
||||
platform: platform,
|
||||
usage: TestUsage(),
|
||||
fileSystem: fileSystem,
|
||||
logger: logger,
|
||||
processManager: processManager,
|
||||
botDetector: const BotDetectorAlwaysNo(),
|
||||
stdio: FakeStdio(),
|
||||
);
|
||||
|
||||
await pub.get(
|
||||
project: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
|
||||
context: PubContext.flutterTests);
|
||||
expect(logger.statusText,
|
||||
contains('Found an existing Pub cache at /global/.pub-cache'));
|
||||
expect(logger.statusText,
|
||||
contains('It can be reset by running `dart pub cache clean`'));
|
||||
expect(
|
||||
logger.statusText,
|
||||
contains(
|
||||
'Found an existing Dart Analysis Server cache at /global/.dartServer'),
|
||||
);
|
||||
expect(preloadCache.existsSync(), false);
|
||||
logger.clear();
|
||||
await pub.get(
|
||||
project: FlutterProject.fromDirectoryTest(fileSystem.currentDirectory),
|
||||
context: PubContext.flutterTests);
|
||||
expect(logger.statusText, isNot(contains('Found an existing Pub cache')));
|
||||
expect(logger.statusText,
|
||||
isNot(contains('Found an existing Dart Analysis Server cache')));
|
||||
expect(processManager, hasNoRemainingExpectations);
|
||||
});
|
||||
|
||||
testWithoutContext('pub cache in environment is used', () async {
|
||||
final FileSystem fileSystem = MemoryFileSystem.test();
|
||||
fileSystem.directory('custom/pub-cache/path').createSync(recursive: true);
|
||||
|
|
Loading…
Reference in a new issue