Skip to content

Commit 5bd8579

Browse files
authored
Use flutter pub get instead of dart pub get in create_api_docs.dart (#133493)
1 parent e8df434 commit 5bd8579

File tree

3 files changed

+159
-157
lines changed

3 files changed

+159
-157
lines changed

dev/tools/create_api_docs.dart

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Future<void> main(List<String> arguments) async {
7777
configurator.generateConfiguration();
7878

7979
final PlatformDocGenerator platformGenerator = PlatformDocGenerator(outputDir: publishRoot, filesystem: filesystem);
80-
platformGenerator.generatePlatformDocs();
80+
await platformGenerator.generatePlatformDocs();
8181

8282
final DartdocGenerator dartdocGenerator = DartdocGenerator(
8383
publishRoot: publishRoot,
@@ -465,7 +465,7 @@ class DartdocGenerator {
465465

466466
// Verify which version of snippets and dartdoc we're using.
467467
final ProcessResult snippetsResult = Process.runSync(
468-
FlutterInformation.instance.getDartBinaryPath().path,
468+
FlutterInformation.instance.getFlutterBinaryPath().path,
469469
<String>[
470470
'pub',
471471
'global',
@@ -779,16 +779,16 @@ class PlatformDocGenerator {
779779

780780
/// This downloads an archive of platform docs for the engine from the artifact
781781
/// store and extracts them to the location used for Dartdoc.
782-
void generatePlatformDocs() {
782+
Future<void> generatePlatformDocs() async {
783783
final String realm = engineRealm.isNotEmpty ? '$engineRealm/' : '';
784784

785785
final String javadocUrl =
786786
'https://storage.googleapis.com/${realm}flutter_infra_release/flutter/$engineRevision/android-javadoc.zip';
787-
_extractDocs(javadocUrl, 'javadoc', 'io/flutter/view/FlutterView.html', outputDir);
787+
await _extractDocs(javadocUrl, 'javadoc', 'io/flutter/view/FlutterView.html', outputDir);
788788

789789
final String objcdocUrl =
790790
'https://storage.googleapis.com/${realm}flutter_infra_release/flutter/$engineRevision/ios-objcdoc.zip';
791-
_extractDocs(objcdocUrl, 'objcdoc', 'Classes/FlutterViewController.html', outputDir);
791+
await _extractDocs(objcdocUrl, 'objcdoc', 'Classes/FlutterViewController.html', outputDir);
792792
}
793793

794794
/// Fetches the zip archive at the specified url.
@@ -935,7 +935,7 @@ Future<Process> runPubProcess({
935935
@visibleForTesting FileSystem filesystem = const LocalFileSystem(),
936936
}) {
937937
return processManager.start(
938-
<Object>[FlutterInformation.instance.getDartBinaryPath().path, 'pub', ...arguments],
938+
<Object>[FlutterInformation.instance.getFlutterBinaryPath().path, 'pub', ...arguments],
939939
workingDirectory: (workingDirectory ?? filesystem.currentDirectory).path,
940940
environment: environment,
941941
);
@@ -968,21 +968,13 @@ List<Directory> findPackages(FileSystem filesystem) {
968968
}
969969

970970
/// An exception class used to indicate problems when collecting information.
971-
class DartdocException implements Exception {
972-
DartdocException(this.message, {this.file, this.line});
971+
class FlutterInformationException implements Exception {
972+
FlutterInformationException(this.message);
973973
final String message;
974-
final String? file;
975-
final int? line;
976974

977975
@override
978976
String toString() {
979-
if (file != null || line != null) {
980-
final String fileStr = file == null ? '' : '$file:';
981-
final String lineStr = line == null ? '' : '$line:';
982-
return '$runtimeType: $fileStr$lineStr: $message';
983-
} else {
984-
return '$runtimeType: $message';
985-
}
977+
return '$runtimeType: $message';
986978
}
987979
}
988980

@@ -1017,6 +1009,13 @@ class FlutterInformation {
10171009
return getFlutterRoot().childDirectory('bin').childFile('dart');
10181010
}
10191011

1012+
/// The path to the Dart binary in the Flutter repo.
1013+
///
1014+
/// This is probably a shell script.
1015+
File getFlutterBinaryPath() {
1016+
return getFlutterRoot().childDirectory('bin').childFile('flutter');
1017+
}
1018+
10201019
/// The path to the Flutter repo root directory.
10211020
///
10221021
/// If the environment variable `FLUTTER_ROOT` is set, will use that instead
@@ -1074,11 +1073,12 @@ class FlutterInformation {
10741073
try {
10751074
result = processManager.runSync(<String>[flutterCommand, '--version', '--machine'], stdoutEncoding: utf8);
10761075
} on ProcessException catch (e) {
1077-
throw DartdocException(
1076+
throw FlutterInformationException(
10781077
'Unable to determine Flutter information. Either set FLUTTER_ROOT, or place flutter command in your path.\n$e');
10791078
}
10801079
if (result.exitCode != 0) {
1081-
throw DartdocException('Unable to determine Flutter information, because of abnormal exit to flutter command.');
1080+
throw FlutterInformationException(
1081+
'Unable to determine Flutter information, because of abnormal exit to flutter command.');
10821082
}
10831083
flutterVersionJson = (result.stdout as String)
10841084
.replaceAll('Waiting for another flutter command to release the startup lock...', '');
@@ -1088,7 +1088,7 @@ class FlutterInformation {
10881088
if (flutterVersion['flutterRoot'] == null ||
10891089
flutterVersion['frameworkVersion'] == null ||
10901090
flutterVersion['dartSdkVersion'] == null) {
1091-
throw DartdocException(
1091+
throw FlutterInformationException(
10921092
'Flutter command output has unexpected format, unable to determine flutter root location.');
10931093
}
10941094

@@ -1097,14 +1097,13 @@ class FlutterInformation {
10971097
info['flutterRoot'] = flutterRoot;
10981098
info['frameworkVersion'] = Version.parse(flutterVersion['frameworkVersion'] as String);
10991099
info['engineRevision'] = flutterVersion['engineRevision'] as String;
1100-
info['engineRealm'] = filesystem.file(
1101-
path.join(flutterRoot.path, 'bin', 'internal', 'engine.realm',
1102-
)).readAsStringSync().trim();
1100+
final File engineRealm = flutterRoot.childDirectory('bin').childDirectory('internal').childFile('engine.realm');
1101+
info['engineRealm'] = engineRealm.existsSync() ? engineRealm.readAsStringSync().trim() : '';
11031102

11041103
final RegExpMatch? dartVersionRegex = RegExp(r'(?<base>[\d.]+)(?:\s+\(build (?<detail>[-.\w]+)\))?')
11051104
.firstMatch(flutterVersion['dartSdkVersion'] as String);
11061105
if (dartVersionRegex == null) {
1107-
throw DartdocException(
1106+
throw FlutterInformationException(
11081107
'Flutter command output has unexpected format, unable to parse dart SDK version ${flutterVersion['dartSdkVersion']}.');
11091108
}
11101109
info['dartSdkVersion'] =

dev/tools/examples_smoke_test.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ import 'package:path/path.dart' as path;
1717
import 'package:platform/platform.dart';
1818
import 'package:process/process.dart';
1919

20-
FileSystem filesystem = const LocalFileSystem();
21-
ProcessManager processManager = const LocalProcessManager();
22-
Platform platform = const LocalPlatform();
20+
const FileSystem _kFilesystem = LocalFileSystem();
21+
const ProcessManager _kProcessManager = LocalProcessManager();
22+
const Platform _kPlatform = LocalPlatform();
2323

2424
FutureOr<dynamic> main() async {
25-
if (!platform.isLinux && !platform.isWindows && !platform.isMacOS) {
25+
if (!_kPlatform.isLinux && !_kPlatform.isWindows && !_kPlatform.isMacOS) {
2626
stderr.writeln('Example smoke tests are only designed to run on desktop platforms');
2727
exitCode = 4;
2828
return;
2929
}
30-
final Directory flutterDir = filesystem.directory(
30+
final Directory flutterDir = _kFilesystem.directory(
3131
path.absolute(
3232
path.dirname(
3333
path.dirname(
34-
path.dirname(platform.script.toFilePath()),
34+
path.dirname(_kPlatform.script.toFilePath()),
3535
),
3636
),
3737
),
@@ -63,16 +63,16 @@ Future<void> runSmokeTests({
6363
required Directory apiDir,
6464
}) async {
6565
final File flutterExe =
66-
flutterDir.childDirectory('bin').childFile(platform.isWindows ? 'flutter.bat' : 'flutter');
66+
flutterDir.childDirectory('bin').childFile(_kPlatform.isWindows ? 'flutter.bat' : 'flutter');
6767
final List<String> cmd = <String>[
6868
// If we're in a container with no X display, then use the virtual framebuffer.
69-
if (platform.isLinux &&
70-
(platform.environment['DISPLAY'] == null ||
71-
platform.environment['DISPLAY']!.isEmpty)) '/usr/bin/xvfb-run',
69+
if (_kPlatform.isLinux &&
70+
(_kPlatform.environment['DISPLAY'] == null ||
71+
_kPlatform.environment['DISPLAY']!.isEmpty)) '/usr/bin/xvfb-run',
7272
flutterExe.absolute.path,
7373
'test',
7474
'--reporter=expanded',
75-
'--device-id=${platform.operatingSystem}',
75+
'--device-id=${_kPlatform.operatingSystem}',
7676
integrationTest.absolute.path,
7777
];
7878
await runCommand(cmd, workingDirectory: apiDir);
@@ -112,7 +112,7 @@ Future<File> generateTest(Directory apiDir) async {
112112
.trim()
113113
.split('\n');
114114
final Iterable<File> examples = gitFiles.map<File>((String examplePath) {
115-
return filesystem.file(path.join(examplesLibDir.absolute.path, examplePath));
115+
return _kFilesystem.file(path.join(examplesLibDir.absolute.path, examplePath));
116116
});
117117

118118
// Collect the examples, and import them all as separate symbols.
@@ -202,7 +202,7 @@ Future<String> runCommand(
202202
}
203203

204204
try {
205-
process = await processManager.start(
205+
process = await _kProcessManager.start(
206206
cmd,
207207
workingDirectory: workingDirectory.absolute.path,
208208
environment: environment,

0 commit comments

Comments
 (0)