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