Unverified Commit 8654e4ae authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

begin migrating //flutter/dev/tools to null-safety (#80834)

parent e5414695
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
// See: https://github.com/flutter/flutter/wiki/Release-process // See: https://github.com/flutter/flutter/wiki/Release-process
import 'dart:io' as io; import 'dart:io' as io;
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:io'; import 'dart:io';
import 'package:path/path.dart' as path; import 'package:path/path.dart' as path;
......
...@@ -29,7 +29,7 @@ Future<void> main(List<String> args) async { ...@@ -29,7 +29,7 @@ Future<void> main(List<String> args) async {
_validate(args); _validate(args);
await _fetchUpstream(); await _fetchUpstream();
await _fetchUpstream(engineRepo); await _fetchUpstream(engineRepo);
String flutterRevision; String? flutterRevision;
await for (final FlutterEngineRevision revision in _logEngineVersions()) { await for (final FlutterEngineRevision revision in _logEngineVersions()) {
if (!await containsRevision(args[0], revision.engineRevision)) { if (!await containsRevision(args[0], revision.engineRevision)) {
if (flutterRevision == null) { if (flutterRevision == null) {
......
...@@ -25,8 +25,8 @@ Future<void> main(List<String> args) async { ...@@ -25,8 +25,8 @@ Future<void> main(List<String> args) async {
/// Fetches the zip archive at the specified url. /// Fetches the zip archive at the specified url.
/// ///
/// Returns null if the archive fails to download after [maxTries] attempts. /// Returns null if the archive fails to download after [maxTries] attempts.
Future<Archive> fetchArchive(String url, int maxTries) async { Future<Archive?> fetchArchive(String url, int maxTries) async {
List<int> responseBytes; List<int>? responseBytes;
for (int i = 0; i < maxTries; i++) { for (int i = 0; i < maxTries; i++) {
final http.Response response = await http.get(Uri.parse(url)); final http.Response response = await http.get(Uri.parse(url));
if (response.statusCode == 200) { if (response.statusCode == 200) {
...@@ -45,7 +45,7 @@ Future<Archive> fetchArchive(String url, int maxTries) async { ...@@ -45,7 +45,7 @@ Future<Archive> fetchArchive(String url, int maxTries) async {
Future<void> generateDocs(String url, String docName, String checkFile) async { Future<void> generateDocs(String url, String docName, String checkFile) async {
const int maxTries = 5; const int maxTries = 5;
final Archive archive = await fetchArchive(url, maxTries); final Archive? archive = await fetchArchive(url, maxTries);
if (archive == null) { if (archive == null) {
stderr.writeln('Failed to fetch zip archive from: $url after $maxTries attempts. Giving up.'); stderr.writeln('Failed to fetch zip archive from: $url after $maxTries attempts. Giving up.');
exit(1); exit(1);
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
......
...@@ -6,7 +6,7 @@ import 'dart:io' as io; ...@@ -6,7 +6,7 @@ import 'dart:io' as io;
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart' show visibleForTesting;
import 'package:platform/platform.dart'; import 'package:platform/platform.dart';
import 'package:process/process.dart'; import 'package:process/process.dart';
...@@ -31,11 +31,10 @@ const String kUpstream = 'upstream'; ...@@ -31,11 +31,10 @@ const String kUpstream = 'upstream';
/// Command to codesign and verify the signatures of cached binaries. /// Command to codesign and verify the signatures of cached binaries.
class CodesignCommand extends Command<void> { class CodesignCommand extends Command<void> {
CodesignCommand({ CodesignCommand({
@required this.checkouts, required this.checkouts,
@required this.flutterRoot, required this.flutterRoot,
FrameworkRepository framework, FrameworkRepository? framework,
}) : assert(flutterRoot != null), }) : fileSystem = checkouts.fileSystem,
fileSystem = checkouts.fileSystem,
platform = checkouts.platform, platform = checkouts.platform,
stdio = checkouts.stdio, stdio = checkouts.stdio,
processManager = checkouts.processManager { processManager = checkouts.processManager {
...@@ -74,7 +73,7 @@ class CodesignCommand extends Command<void> { ...@@ -74,7 +73,7 @@ class CodesignCommand extends Command<void> {
/// Root directory of the Flutter repository. /// Root directory of the Flutter repository.
final Directory flutterRoot; final Directory flutterRoot;
FrameworkRepository _framework; FrameworkRepository? _framework;
FrameworkRepository get framework { FrameworkRepository get framework {
return _framework ??= FrameworkRepository.localRepoAsUpstream( return _framework ??= FrameworkRepository.localRepoAsUpstream(
checkouts, checkouts,
...@@ -97,21 +96,21 @@ class CodesignCommand extends Command<void> { ...@@ -97,21 +96,21 @@ class CodesignCommand extends Command<void> {
'"${platform.operatingSystem}"'); '"${platform.operatingSystem}"');
} }
if (argResults['verify'] as bool != true) { if (argResults!['verify'] as bool != true) {
throw ConductorException( throw ConductorException(
'Sorry, but codesigning is not implemented yet. Please pass the ' 'Sorry, but codesigning is not implemented yet. Please pass the '
'--$kVerify flag to verify signatures.'); '--$kVerify flag to verify signatures.');
} }
String revision; String revision;
if (argResults.wasParsed(kRevision)) { if (argResults!.wasParsed(kRevision)) {
stdio.printError( stdio.printError(
'Warning! When providing an arbitrary revision, the contents of the cache may not'); 'Warning! When providing an arbitrary revision, the contents of the cache may not');
stdio.printError( stdio.printError(
'match the expected binaries in the conductor tool. It is preferred to check out'); 'match the expected binaries in the conductor tool. It is preferred to check out');
stdio.printError( stdio.printError(
'the desired revision and run that version of the conductor.\n'); 'the desired revision and run that version of the conductor.\n');
revision = argResults[kRevision] as String; revision = argResults![kRevision] as String;
} else { } else {
revision = (processManager.runSync( revision = (processManager.runSync(
<String>['git', 'rev-parse', 'HEAD'], <String>['git', 'rev-parse', 'HEAD'],
...@@ -127,7 +126,7 @@ class CodesignCommand extends Command<void> { ...@@ -127,7 +126,7 @@ class CodesignCommand extends Command<void> {
framework.runFlutter(<String>['precache', '--android', '--ios', '--macos']); framework.runFlutter(<String>['precache', '--android', '--ios', '--macos']);
verifyExist(); verifyExist();
if (argResults[kSignatures] as bool) { if (argResults![kSignatures] as bool) {
verifySignatures(); verifySignatures();
} }
} }
...@@ -319,16 +318,16 @@ class CodesignCommand extends Command<void> { ...@@ -319,16 +318,16 @@ class CodesignCommand extends Command<void> {
} }
stdio.printStatus( stdio.printStatus(
'Verified that binaries for commit ${argResults[kRevision] as String} are codesigned and have ' 'Verified that binaries for commit ${argResults![kRevision] as String} are codesigned and have '
'expected entitlements.'); 'expected entitlements.');
} }
List<String> _allBinaryPaths; List<String>? _allBinaryPaths;
/// Find every binary file in the given [rootDirectory]. /// Find every binary file in the given [rootDirectory].
List<String> findBinaryPaths(String rootDirectory) { List<String> findBinaryPaths(String rootDirectory) {
if (_allBinaryPaths != null) { if (_allBinaryPaths != null) {
return _allBinaryPaths; return _allBinaryPaths!;
} }
final io.ProcessResult result = processManager.runSync( final io.ProcessResult result = processManager.runSync(
<String>[ <String>[
...@@ -343,7 +342,7 @@ class CodesignCommand extends Command<void> { ...@@ -343,7 +342,7 @@ class CodesignCommand extends Command<void> {
.where((String s) => s.isNotEmpty) .where((String s) => s.isNotEmpty)
.toList(); .toList();
_allBinaryPaths = allFiles.where(isBinary).toList(); _allBinaryPaths = allFiles.where(isBinary).toList();
return _allBinaryPaths; return _allBinaryPaths!;
} }
/// Check mime-type of file at [filePath] to determine if it is binary. /// Check mime-type of file at [filePath] to determine if it is binary.
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
import 'dart:io'; import 'dart:io';
import 'package:meta/meta.dart';
import 'package:process/process.dart'; import 'package:process/process.dart';
import './globals.dart'; import './globals.dart';
...@@ -18,7 +17,7 @@ class Git { ...@@ -18,7 +17,7 @@ class Git {
String getOutput( String getOutput(
List<String> args, List<String> args,
String explanation, { String explanation, {
@required String workingDirectory, required String workingDirectory,
bool allowFailures = false, bool allowFailures = false,
}) { }) {
final ProcessResult result = _run(args, workingDirectory); final ProcessResult result = _run(args, workingDirectory);
...@@ -26,14 +25,13 @@ class Git { ...@@ -26,14 +25,13 @@ class Git {
return stdoutToString(result.stdout); return stdoutToString(result.stdout);
} }
_reportFailureAndExit(args, workingDirectory, result, explanation); _reportFailureAndExit(args, workingDirectory, result, explanation);
return null; // for the analyzer's sake
} }
int run( int run(
List<String> args, List<String> args,
String explanation, { String explanation, {
bool allowNonZeroExitCode = false, bool allowNonZeroExitCode = false,
@required String workingDirectory, required String workingDirectory,
}) { }) {
final ProcessResult result = _run(args, workingDirectory); final ProcessResult result = _run(args, workingDirectory);
if (result.exitCode != 0 && !allowNonZeroExitCode) { if (result.exitCode != 0 && !allowNonZeroExitCode) {
...@@ -50,7 +48,7 @@ class Git { ...@@ -50,7 +48,7 @@ class Git {
); );
} }
void _reportFailureAndExit( Never _reportFailureAndExit(
List<String> args, List<String> args,
String workingDirectory, String workingDirectory,
ProcessResult result, ProcessResult result,
......
...@@ -39,10 +39,10 @@ class ConductorException implements Exception { ...@@ -39,10 +39,10 @@ class ConductorException implements Exception {
String toString() => 'Exception: $message'; String toString() => 'Exception: $message';
} }
Directory _flutterRoot; Directory? _flutterRoot;
Directory get localFlutterRoot { Directory get localFlutterRoot {
if (_flutterRoot != null) { if (_flutterRoot != null) {
return _flutterRoot; return _flutterRoot!;
} }
String filePath; String filePath;
const FileSystem fileSystem = LocalFileSystem(); const FileSystem fileSystem = LocalFileSystem();
...@@ -54,14 +54,14 @@ Directory get localFlutterRoot { ...@@ -54,14 +54,14 @@ Directory get localFlutterRoot {
r'(file:\/\/[^"]*[/\\]dev\/tools[/\\][^"]+\.dart)', r'(file:\/\/[^"]*[/\\]dev\/tools[/\\][^"]+\.dart)',
multiLine: true, multiLine: true,
); );
final Match match = final Match? match =
pattern.firstMatch(Uri.decodeFull(platform.script.path)); pattern.firstMatch(Uri.decodeFull(platform.script.path));
if (match == null) { if (match == null) {
throw Exception( throw Exception(
'Cannot determine path of script!\n${platform.script.path}', 'Cannot determine path of script!\n${platform.script.path}',
); );
} }
filePath = Uri.parse(match.group(1)).path.replaceAll(r'%20', ' '); filePath = Uri.parse(match.group(1)!).path.replaceAll(r'%20', ' ');
} else { } else {
filePath = platform.script.toFilePath(); filePath = platform.script.toFilePath();
} }
...@@ -74,7 +74,7 @@ Directory get localFlutterRoot { ...@@ -74,7 +74,7 @@ Directory get localFlutterRoot {
), ),
); );
_flutterRoot = fileSystem.directory(checkoutsDirname); _flutterRoot = fileSystem.directory(checkoutsDirname);
return _flutterRoot; return _flutterRoot!;
} }
bool assertsEnabled() { bool assertsEnabled() {
...@@ -102,9 +102,9 @@ String getValueFromEnvOrArgs( ...@@ -102,9 +102,9 @@ String getValueFromEnvOrArgs(
) { ) {
final String envName = fromArgToEnvName(name); final String envName = fromArgToEnvName(name);
if (env[envName] != null ) { if (env[envName] != null ) {
return env[envName]; return env[envName]!;
} }
final String argValue = argResults[name] as String; final String? argValue = argResults[name] as String?;
if (argValue != null) { if (argValue != null) {
return argValue; return argValue;
} }
...@@ -130,7 +130,7 @@ List<String> getValuesFromEnvOrArgs( ...@@ -130,7 +130,7 @@ List<String> getValuesFromEnvOrArgs(
) { ) {
final String envName = fromArgToEnvName(name); final String envName = fromArgToEnvName(name);
if (env[envName] != null && env[envName] != '') { if (env[envName] != null && env[envName] != '') {
return env[envName].split(','); return env[envName]!.split(',');
} }
final List<String> argValues = argResults[name] as List<String>; final List<String> argValues = argResults[name] as List<String>;
if (argValues != null) { if (argValues != null) {
......
...@@ -23,8 +23,8 @@ enum RemoteName { ...@@ -23,8 +23,8 @@ enum RemoteName {
class Remote { class Remote {
const Remote({ const Remote({
@required RemoteName name, required RemoteName name,
@required this.url, required this.url,
}) : _name = name; }) : _name = name;
final RemoteName _name; final RemoteName _name;
...@@ -37,7 +37,6 @@ class Remote { ...@@ -37,7 +37,6 @@ class Remote {
case RemoteName.mirror: case RemoteName.mirror:
return 'mirror'; return 'mirror';
} }
throw ConductorException('Invalid value of _name: $_name'); // For analyzer
} }
/// The URL of the remote. /// The URL of the remote.
...@@ -47,13 +46,13 @@ class Remote { ...@@ -47,13 +46,13 @@ class Remote {
/// A source code repository. /// A source code repository.
abstract class Repository { abstract class Repository {
Repository({ Repository({
@required this.name, required this.name,
@required this.fetchRemote, required this.fetchRemote,
@required this.processManager, required this.processManager,
@required this.stdio, required this.stdio,
@required this.platform, required this.platform,
@required this.fileSystem, required this.fileSystem,
@required this.parentDirectory, required this.parentDirectory,
this.initialRef, this.initialRef,
this.localUpstream = false, this.localUpstream = false,
this.useExistingCheckout = false, this.useExistingCheckout = false,
...@@ -69,10 +68,10 @@ abstract class Repository { ...@@ -69,10 +68,10 @@ abstract class Repository {
/// ///
/// This value can be null, in which case attempting to publish will lead to /// This value can be null, in which case attempting to publish will lead to
/// a [ConductorException]. /// a [ConductorException].
final Remote pushRemote; final Remote? pushRemote;
/// The initial ref (branch or commit name) to check out. /// The initial ref (branch or commit name) to check out.
final String initialRef; final String? initialRef;
final Git git; final Git git;
final ProcessManager processManager; final ProcessManager processManager;
final Stdio stdio; final Stdio stdio;
...@@ -84,7 +83,7 @@ abstract class Repository { ...@@ -84,7 +83,7 @@ abstract class Repository {
/// If the repository will be used as an upstream for a test repo. /// If the repository will be used as an upstream for a test repo.
final bool localUpstream; final bool localUpstream;
Directory _checkoutDirectory; Directory? _checkoutDirectory;
/// Directory for the repository checkout. /// Directory for the repository checkout.
/// ///
...@@ -92,23 +91,23 @@ abstract class Repository { ...@@ -92,23 +91,23 @@ abstract class Repository {
/// cloned on the filesystem until this getter is accessed. /// cloned on the filesystem until this getter is accessed.
Directory get checkoutDirectory { Directory get checkoutDirectory {
if (_checkoutDirectory != null) { if (_checkoutDirectory != null) {
return _checkoutDirectory; return _checkoutDirectory!;
} }
_checkoutDirectory = parentDirectory.childDirectory(name); _checkoutDirectory = parentDirectory.childDirectory(name);
lazilyInitialize(); lazilyInitialize(_checkoutDirectory!);
return _checkoutDirectory; return _checkoutDirectory!;
} }
/// Ensure the repository is cloned to disk and initialized with proper state. /// Ensure the repository is cloned to disk and initialized with proper state.
void lazilyInitialize() { void lazilyInitialize(Directory checkoutDirectory) {
if (!useExistingCheckout && _checkoutDirectory.existsSync()) { if (!useExistingCheckout && checkoutDirectory.existsSync()) {
stdio.printTrace('Deleting $name from ${_checkoutDirectory.path}...'); stdio.printTrace('Deleting $name from ${checkoutDirectory.path}...');
_checkoutDirectory.deleteSync(recursive: true); checkoutDirectory.deleteSync(recursive: true);
} }
if (!_checkoutDirectory.existsSync()) { if (!checkoutDirectory.existsSync()) {
stdio.printTrace( stdio.printTrace(
'Cloning $name from ${fetchRemote.url} to ${_checkoutDirectory.path}...', 'Cloning $name from ${fetchRemote.url} to ${checkoutDirectory.path}...',
); );
git.run( git.run(
<String>[ <String>[
...@@ -117,21 +116,21 @@ abstract class Repository { ...@@ -117,21 +116,21 @@ abstract class Repository {
fetchRemote.name, fetchRemote.name,
'--', '--',
fetchRemote.url, fetchRemote.url,
_checkoutDirectory.path checkoutDirectory.path
], ],
'Cloning $name repo', 'Cloning $name repo',
workingDirectory: parentDirectory.path, workingDirectory: parentDirectory.path,
); );
if (pushRemote != null) { if (pushRemote != null) {
git.run( git.run(
<String>['remote', 'add', pushRemote.name, pushRemote.url], <String>['remote', 'add', pushRemote!.name, pushRemote!.url],
'Adding remote ${pushRemote.url} as ${pushRemote.name}', 'Adding remote ${pushRemote!.url} as ${pushRemote!.name}',
workingDirectory: _checkoutDirectory.path, workingDirectory: checkoutDirectory.path,
); );
git.run( git.run(
<String>['fetch', pushRemote.name], <String>['fetch', pushRemote!.name],
'Fetching git remote ${pushRemote.name}', 'Fetching git remote ${pushRemote!.name}',
workingDirectory: _checkoutDirectory.path, workingDirectory: checkoutDirectory.path,
); );
} }
if (localUpstream) { if (localUpstream) {
...@@ -141,7 +140,7 @@ abstract class Repository { ...@@ -141,7 +140,7 @@ abstract class Repository {
git.run( git.run(
<String>['checkout', channel, '--'], <String>['checkout', channel, '--'],
'check out branch $channel locally', 'check out branch $channel locally',
workingDirectory: _checkoutDirectory.path, workingDirectory: checkoutDirectory.path,
); );
} }
} }
...@@ -151,7 +150,7 @@ abstract class Repository { ...@@ -151,7 +150,7 @@ abstract class Repository {
git.run( git.run(
<String>['checkout', '${fetchRemote.name}/$initialRef'], <String>['checkout', '${fetchRemote.name}/$initialRef'],
'Checking out initialRef $initialRef', 'Checking out initialRef $initialRef',
workingDirectory: _checkoutDirectory.path, workingDirectory: checkoutDirectory.path,
); );
} }
final String revision = reverseParse('HEAD'); final String revision = reverseParse('HEAD');
...@@ -404,8 +403,8 @@ class FrameworkRepository extends Repository { ...@@ -404,8 +403,8 @@ class FrameworkRepository extends Repository {
name: RemoteName.upstream, url: FrameworkRepository.defaultUpstream), name: RemoteName.upstream, url: FrameworkRepository.defaultUpstream),
bool localUpstream = false, bool localUpstream = false,
bool useExistingCheckout = false, bool useExistingCheckout = false,
String initialRef, String? initialRef,
Remote pushRemote, Remote? pushRemote,
}) : super( }) : super(
name: name, name: name,
fetchRemote: fetchRemote, fetchRemote: fetchRemote,
...@@ -428,7 +427,7 @@ class FrameworkRepository extends Repository { ...@@ -428,7 +427,7 @@ class FrameworkRepository extends Repository {
Checkouts checkouts, { Checkouts checkouts, {
String name = 'framework', String name = 'framework',
bool useExistingCheckout = false, bool useExistingCheckout = false,
@required String upstreamPath, required String upstreamPath,
}) { }) {
return FrameworkRepository( return FrameworkRepository(
checkouts, checkouts,
...@@ -455,7 +454,7 @@ class FrameworkRepository extends Repository { ...@@ -455,7 +454,7 @@ class FrameworkRepository extends Repository {
); );
@override @override
Repository cloneRepository(String cloneName) { Repository cloneRepository(String? cloneName) {
assert(localUpstream); assert(localUpstream);
cloneName ??= 'clone-of-$name'; cloneName ??= 'clone-of-$name';
return FrameworkRepository( return FrameworkRepository(
...@@ -529,7 +528,7 @@ class EngineRepository extends Repository { ...@@ -529,7 +528,7 @@ class EngineRepository extends Repository {
name: RemoteName.upstream, url: EngineRepository.defaultUpstream), name: RemoteName.upstream, url: EngineRepository.defaultUpstream),
bool localUpstream = false, bool localUpstream = false,
bool useExistingCheckout = false, bool useExistingCheckout = false,
Remote pushRemote, Remote? pushRemote,
}) : super( }) : super(
name: name, name: name,
fetchRemote: fetchRemote, fetchRemote: fetchRemote,
...@@ -550,7 +549,7 @@ class EngineRepository extends Repository { ...@@ -550,7 +549,7 @@ class EngineRepository extends Repository {
static const String defaultBranch = 'master'; static const String defaultBranch = 'master';
@override @override
Repository cloneRepository(String cloneName) { Repository cloneRepository(String? cloneName) {
assert(localUpstream); assert(localUpstream);
cloneName ??= 'clone-of-$name'; cloneName ??= 'clone-of-$name';
return EngineRepository( return EngineRepository(
...@@ -571,14 +570,13 @@ enum RepositoryType { ...@@ -571,14 +570,13 @@ enum RepositoryType {
class Checkouts { class Checkouts {
Checkouts({ Checkouts({
@required this.fileSystem, required this.fileSystem,
@required this.platform, required this.platform,
@required this.processManager, required this.processManager,
@required this.stdio, required this.stdio,
@required Directory parentDirectory, required Directory parentDirectory,
String directoryName = 'flutter_conductor_checkouts', String directoryName = 'flutter_conductor_checkouts',
}) : assert(parentDirectory != null), }) : directory = parentDirectory.childDirectory(directoryName) {
directory = parentDirectory.childDirectory(directoryName) {
if (!directory.existsSync()) { if (!directory.existsSync()) {
directory.createSync(recursive: true); directory.createSync(recursive: true);
} }
......
...@@ -23,10 +23,10 @@ const String kSkipTagging = 'skip-tagging'; ...@@ -23,10 +23,10 @@ const String kSkipTagging = 'skip-tagging';
/// Create a new dev release without cherry picks. /// Create a new dev release without cherry picks.
class RollDevCommand extends Command<void> { class RollDevCommand extends Command<void> {
RollDevCommand({ RollDevCommand({
@required this.checkouts, required this.checkouts,
@required this.fileSystem, required this.fileSystem,
@required this.platform, required this.platform,
@required this.stdio, required this.stdio,
}) { }) {
argParser.addOption( argParser.addOption(
kIncrement, kIncrement,
...@@ -92,7 +92,7 @@ class RollDevCommand extends Command<void> { ...@@ -92,7 +92,7 @@ class RollDevCommand extends Command<void> {
@override @override
void run() { void run() {
rollDev( rollDev(
argResults: argResults, argResults: argResults!,
repository: FrameworkRepository(checkouts), repository: FrameworkRepository(checkouts),
stdio: stdio, stdio: stdio,
usage: argParser.usage, usage: argParser.usage,
...@@ -105,10 +105,10 @@ class RollDevCommand extends Command<void> { ...@@ -105,10 +105,10 @@ class RollDevCommand extends Command<void> {
/// Returns true if publishing was successful, else false. /// Returns true if publishing was successful, else false.
@visibleForTesting @visibleForTesting
bool rollDev({ bool rollDev({
@required String usage, required String usage,
@required ArgResults argResults, required ArgResults argResults,
@required Stdio stdio, required Stdio stdio,
@required FrameworkRepository repository, required FrameworkRepository repository,
}) { }) {
final String remoteName = argResults[kRemoteName] as String; final String remoteName = argResults[kRemoteName] as String;
final String level = argResults[kIncrement] as String; final String level = argResults[kIncrement] as String;
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:convert' show jsonEncode; import 'dart:convert' show jsonEncode;
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:platform/platform.dart'; import 'package:platform/platform.dart';
import './globals.dart'; import './globals.dart';
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:convert' show jsonDecode; import 'dart:convert' show jsonDecode;
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
......
...@@ -40,10 +40,10 @@ abstract class Stdio { ...@@ -40,10 +40,10 @@ abstract class Stdio {
/// A logger that will print out trace messages. /// A logger that will print out trace messages.
class VerboseStdio extends Stdio { class VerboseStdio extends Stdio {
VerboseStdio({ VerboseStdio({
@required this.stdout, required this.stdout,
@required this.stderr, required this.stderr,
@required this.stdin, required this.stdin,
}) : assert(stdout != null), assert(stderr != null), assert(stdin != null); });
factory VerboseStdio.local() => VerboseStdio( factory VerboseStdio.local() => VerboseStdio(
stdout: io.stdout, stdout: io.stdout,
...@@ -81,6 +81,6 @@ class VerboseStdio extends Stdio { ...@@ -81,6 +81,6 @@ class VerboseStdio extends Stdio {
@override @override
String readLineSync() { String readLineSync() {
return stdin.readLineSync(); return stdin.readLineSync()!;
} }
} }
...@@ -2,18 +2,18 @@ ...@@ -2,18 +2,18 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:meta/meta.dart';
/// Possible string formats that `flutter --version` can return. /// Possible string formats that `flutter --version` can return.
enum VersionType { enum VersionType {
/// A stable flutter release. /// A stable flutter release.
/// ///
/// Example: '1.2.3' /// Example: '1.2.3'
stable, stable,
/// A pre-stable flutter release. /// A pre-stable flutter release.
/// ///
/// Example: '1.2.3-4.5.pre' /// Example: '1.2.3-4.5.pre'
development, development,
/// A master channel flutter version. /// A master channel flutter version.
/// ///
/// Example: '1.2.3-4.0.pre.10' /// Example: '1.2.3-4.0.pre.10'
...@@ -30,13 +30,13 @@ final Map<VersionType, RegExp> versionPatterns = <VersionType, RegExp>{ ...@@ -30,13 +30,13 @@ final Map<VersionType, RegExp> versionPatterns = <VersionType, RegExp>{
class Version { class Version {
Version({ Version({
@required this.x, required this.x,
@required this.y, required this.y,
@required this.z, required this.z,
this.m, this.m,
this.n, this.n,
this.commits, this.commits,
@required this.type, required this.type,
}) { }) {
switch (type) { switch (type) {
case VersionType.stable: case VersionType.stable:
...@@ -67,11 +67,13 @@ class Version { ...@@ -67,11 +67,13 @@ class Version {
versionString = versionString.trim(); versionString = versionString.trim();
// stable tag // stable tag
Match match = versionPatterns[VersionType.stable].firstMatch(versionString); Match? match = versionPatterns[VersionType.stable]!.firstMatch(versionString);
if (match != null) { if (match != null) {
// parse stable // parse stable
final List<int> parts = final List<int> parts = match
match.groups(<int>[1, 2, 3]).map(int.parse).toList(); .groups(<int>[1, 2, 3])
.map((String? s) => int.parse(s!))
.toList();
return Version( return Version(
x: parts[0], x: parts[0],
y: parts[1], y: parts[1],
...@@ -80,11 +82,11 @@ class Version { ...@@ -80,11 +82,11 @@ class Version {
); );
} }
// development tag // development tag
match = versionPatterns[VersionType.development].firstMatch(versionString); match = versionPatterns[VersionType.development]!.firstMatch(versionString);
if (match != null) { if (match != null) {
// parse development // parse development
final List<int> parts = final List<int> parts =
match.groups(<int>[1, 2, 3, 4, 5]).map(int.parse).toList(); match.groups(<int>[1, 2, 3, 4, 5]).map((String? s) => int.parse(s!)).toList();
return Version( return Version(
x: parts[0], x: parts[0],
y: parts[1], y: parts[1],
...@@ -95,11 +97,14 @@ class Version { ...@@ -95,11 +97,14 @@ class Version {
); );
} }
// latest tag // latest tag
match = versionPatterns[VersionType.latest].firstMatch(versionString); match = versionPatterns[VersionType.latest]!.firstMatch(versionString);
if (match != null) { if (match != null) {
// parse latest // parse latest
final List<int> parts = final List<int> parts = match.groups(
match.groups(<int>[1, 2, 3, 4, 5, 6]).map(int.parse).toList(); <int>[1, 2, 3, 4, 5, 6],
).map(
(String? s) => int.parse(s!),
).toList();
return Version( return Version(
x: parts[0], x: parts[0],
y: parts[1], y: parts[1],
...@@ -118,13 +123,13 @@ class Version { ...@@ -118,13 +123,13 @@ class Version {
factory Version.increment( factory Version.increment(
Version previousVersion, Version previousVersion,
String increment, { String increment, {
VersionType nextVersionType, VersionType? nextVersionType,
}) { }) {
final int nextX = previousVersion.x; final int nextX = previousVersion.x;
int nextY = previousVersion.y; int nextY = previousVersion.y;
int nextZ = previousVersion.z; int nextZ = previousVersion.z;
int nextM = previousVersion.m; int? nextM = previousVersion.m;
int nextN = previousVersion.n; int? nextN = previousVersion.n;
if (nextVersionType == null) { if (nextVersionType == null) {
if (previousVersion.type == VersionType.latest) { if (previousVersion.type == VersionType.latest) {
nextVersionType = VersionType.development; nextVersionType = VersionType.development;
...@@ -137,7 +142,6 @@ class Version { ...@@ -137,7 +142,6 @@ class Version {
case 'x': case 'x':
// This was probably a mistake. // This was probably a mistake.
throw Exception('Incrementing x is not supported by this tool.'); throw Exception('Incrementing x is not supported by this tool.');
break;
case 'y': case 'y':
// Dev release following a beta release. // Dev release following a beta release.
nextY += 1; nextY += 1;
...@@ -155,13 +159,12 @@ class Version { ...@@ -155,13 +159,12 @@ class Version {
case 'm': case 'm':
// Regular dev release. // Regular dev release.
assert(previousVersion.type == VersionType.development); assert(previousVersion.type == VersionType.development);
assert(nextM != null); nextM = nextM! + 1;
nextM += 1;
nextN = 0; nextN = 0;
break; break;
case 'n': case 'n':
// Hotfix to internal roll. // Hotfix to internal roll.
nextN += 1; nextN = nextN! + 1;
break; break;
default: default:
throw Exception('Unknown increment level $increment.'); throw Exception('Unknown increment level $increment.');
...@@ -186,13 +189,13 @@ class Version { ...@@ -186,13 +189,13 @@ class Version {
final int z; final int z;
/// Zero-indexed count of dev releases after a beta release. /// Zero-indexed count of dev releases after a beta release.
final int m; final int? m;
/// Number of hotfixes required to make a dev release. /// Number of hotfixes required to make a dev release.
final int n; final int? n;
/// Number of commits past last tagged dev release. /// Number of commits past last tagged dev release.
final int commits; final int? commits;
final VersionType type; final VersionType type;
...@@ -206,6 +209,5 @@ class Version { ...@@ -206,6 +209,5 @@ class Version {
case VersionType.latest: case VersionType.latest:
return '$x.$y.$z-$m.$n.pre.$commits'; return '$x.$y.$z-$m.$n.pre.$commits';
} }
return null; // For analyzer
} }
} }
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
// This utility is run by `gen_localizations.dart` if --overwrite is passed // This utility is run by `gen_localizations.dart` if --overwrite is passed
// in as an option. // in as an option.
// @dart = 2.8
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
/// This program extracts localized date symbols and patterns from the intl /// This program extracts localized date symbols and patterns from the intl
/// package for the subset of locales supported by the flutter_localizations /// package for the subset of locales supported by the flutter_localizations
/// package. /// package.
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
// This program generates a getMaterialTranslation() and a // This program generates a getMaterialTranslation() and a
// getCupertinoTranslation() function that look up the translations provided by // getCupertinoTranslation() function that look up the translations provided by
// the arb files. The returned value is a generated instance of a // the arb files. The returned value is a generated instance of a
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
// This program updates the language locale arb files with any missing resource // This program updates the language locale arb files with any missing resource
// entries that are included in the English arb files. This is useful when // entries that are included in the English arb files. This is useful when
// adding new resources for localization. You can just add the appropriate // adding new resources for localization. You can just add the appropriate
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'localizations_utils.dart'; import 'localizations_utils.dart';
String generateCupertinoHeader(String regenerateInstructions) { String generateCupertinoHeader(String regenerateInstructions) {
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'localizations_utils.dart'; import 'localizations_utils.dart';
String generateMaterialHeader(String regenerateInstructions) { String generateMaterialHeader(String regenerateInstructions) {
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:convert'; import 'dart:convert';
import 'dart:io'; import 'dart:io';
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:convert' show json; import 'dart:convert' show json;
import 'dart:io'; import 'dart:io';
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
/// Make `n` copies of flutter_gallery. /// Make `n` copies of flutter_gallery.
import 'dart:io'; import 'dart:io';
......
...@@ -2,7 +2,7 @@ name: dev_tools ...@@ -2,7 +2,7 @@ name: dev_tools
description: Various repository development tools for flutter. description: Various repository development tools for flutter.
environment: environment:
sdk: ">=2.6.0 <3.0.0" sdk: ">=2.12.0 <3.0.0"
dependencies: dependencies:
archive: 3.1.2 archive: 3.1.2
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:dev_tools/clean.dart'; import 'package:dev_tools/clean.dart';
import 'package:dev_tools/repository.dart'; import 'package:dev_tools/repository.dart';
......
...@@ -8,7 +8,6 @@ import 'package:dev_tools/globals.dart'; ...@@ -8,7 +8,6 @@ import 'package:dev_tools/globals.dart';
import 'package:dev_tools/repository.dart'; import 'package:dev_tools/repository.dart';
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:meta/meta.dart';
import 'package:platform/platform.dart'; import 'package:platform/platform.dart';
import '../../../packages/flutter_tools/test/src/fake_process_manager.dart'; import '../../../packages/flutter_tools/test/src/fake_process_manager.dart';
...@@ -23,12 +22,12 @@ void main() { ...@@ -23,12 +22,12 @@ void main() {
const String flutterBin = const String flutterBin =
'${checkoutsParentDirectory}flutter_conductor_checkouts/framework/bin/flutter'; '${checkoutsParentDirectory}flutter_conductor_checkouts/framework/bin/flutter';
const String revision = 'abcd1234'; const String revision = 'abcd1234';
CommandRunner<void> runner; late CommandRunner<void> runner;
Checkouts checkouts; late Checkouts checkouts;
MemoryFileSystem fileSystem; late MemoryFileSystem fileSystem;
FakePlatform platform; late FakePlatform platform;
TestStdio stdio; late TestStdio stdio;
FakeProcessManager processManager; late FakeProcessManager processManager;
const List<String> binariesWithEntitlements = <String>[ const List<String> binariesWithEntitlements = <String>[
'$flutterCache/dart-sdk/bin/dart', '$flutterCache/dart-sdk/bin/dart',
'$flutterCache/dart-sdk/bin/dartaotruntime', '$flutterCache/dart-sdk/bin/dartaotruntime',
...@@ -43,7 +42,7 @@ void main() { ...@@ -43,7 +42,7 @@ void main() {
void createRunner({ void createRunner({
String operatingSystem = 'macos', String operatingSystem = 'macos',
List<FakeCommand> commands, List<FakeCommand>? commands,
}) { }) {
stdio = TestStdio(); stdio = TestStdio();
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
...@@ -410,10 +409,10 @@ void main() { ...@@ -410,10 +409,10 @@ void main() {
class FakeCodesignCommand extends CodesignCommand { class FakeCodesignCommand extends CodesignCommand {
FakeCodesignCommand({ FakeCodesignCommand({
@required Checkouts checkouts, required Checkouts checkouts,
@required this.binariesWithEntitlements, required this.binariesWithEntitlements,
@required this.binariesWithoutEntitlements, required this.binariesWithoutEntitlements,
@required Directory flutterRoot, required Directory flutterRoot,
}) : super(checkouts: checkouts, flutterRoot: flutterRoot); }) : super(checkouts: checkouts, flutterRoot: flutterRoot);
@override @override
......
...@@ -38,10 +38,8 @@ Matcher throwsExceptionWith(String messageSubString) { ...@@ -38,10 +38,8 @@ Matcher throwsExceptionWith(String messageSubString) {
class TestStdio extends Stdio { class TestStdio extends Stdio {
TestStdio({ TestStdio({
this.verbose = false, this.verbose = false,
List<String> stdin, List<String>? stdin,
}) { }) : _stdin = stdin ?? <String>[];
_stdin = stdin ?? <String>[];
}
String get error => logs.where((String log) => log.startsWith(r'[error] ')).join('\n'); String get error => logs.where((String log) => log.startsWith(r'[error] ')).join('\n');
...@@ -50,7 +48,7 @@ class TestStdio extends Stdio { ...@@ -50,7 +48,7 @@ class TestStdio extends Stdio {
}).join('\n'); }).join('\n');
final bool verbose; final bool verbose;
List<String> _stdin; late final List<String> _stdin;
@override @override
String readLineSync() { String readLineSync() {
...@@ -63,9 +61,9 @@ class TestStdio extends Stdio { ...@@ -63,9 +61,9 @@ class TestStdio extends Stdio {
class FakeArgResults implements ArgResults { class FakeArgResults implements ArgResults {
FakeArgResults({ FakeArgResults({
String level, required String level,
String commit, required String commit,
String remote, String remote = 'upstream',
bool justPrint = false, bool justPrint = false,
bool autoApprove = true, // so we don't have to mock stdin bool autoApprove = true, // so we don't have to mock stdin
bool help = false, bool help = false,
...@@ -83,22 +81,26 @@ class FakeArgResults implements ArgResults { ...@@ -83,22 +81,26 @@ class FakeArgResults implements ArgResults {
}; };
@override @override
String name; String? name;
@override @override
ArgResults command; ArgResults? command;
@override @override
final List<String> rest = <String>[]; final List<String> rest = <String>[];
@override @override
List<String> arguments; List<String> get arguments {
assert(false, 'not yet implemented');
return <String>[];
}
final Map<String, dynamic> _parsedArgs; final Map<String, dynamic> _parsedArgs;
@override @override
Iterable<String> get options { Iterable<String> get options {
return null; assert(false, 'not yet implemented');
return <String>[];
} }
@override @override
...@@ -108,6 +110,7 @@ class FakeArgResults implements ArgResults { ...@@ -108,6 +110,7 @@ class FakeArgResults implements ArgResults {
@override @override
bool wasParsed(String name) { bool wasParsed(String name) {
return null; assert(false, 'not yet implemented');
return false;
} }
} }
...@@ -14,16 +14,16 @@ import './common.dart'; ...@@ -14,16 +14,16 @@ import './common.dart';
void main() { void main() {
group('roll-dev', () { group('roll-dev', () {
TestStdio stdio; late TestStdio stdio;
Platform platform; late Platform platform;
ProcessManager processManager; late ProcessManager processManager;
FileSystem fileSystem; late FileSystem fileSystem;
const String usageString = 'Usage: flutter conductor.'; const String usageString = 'Usage: flutter conductor.';
Checkouts checkouts; late Checkouts checkouts;
FrameworkRepository frameworkUpstream; late FrameworkRepository frameworkUpstream;
FrameworkRepository framework; late FrameworkRepository framework;
Directory tempDir; late Directory tempDir;
setUp(() { setUp(() {
platform = const LocalPlatform(); platform = const LocalPlatform();
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:dev_tools/globals.dart'; import 'package:dev_tools/globals.dart';
import 'package:dev_tools/repository.dart'; import 'package:dev_tools/repository.dart';
import 'package:dev_tools/roll_dev.dart'; import 'package:dev_tools/roll_dev.dart';
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:convert' show jsonDecode; import 'dart:convert' show jsonDecode;
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
// Regenerates the material icons file. // Regenerates the material icons file.
// See https://github.com/flutter/flutter/wiki/Updating-Material-Design-Fonts-&-Icons // See https://github.com/flutter/flutter/wiki/Updating-Material-Design-Fonts-&-Icons
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment