Michael Goderbauer 5491c8c146
Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the
`engine` subdirectory and enforces that these files stay formatted with
a presubmit check.

**Reviewers:** Please carefully review all the commits except for the
one titled "formatted". The "formatted" commit was auto-generated by
running `dev/tools/format.sh -a -f`. The other commits were hand-crafted
to prepare the repo for the formatting change. I recommend reviewing the
commits one-by-one via the "Commits" tab and avoiding Github's "Files
changed" tab as it will likely slow down your browser because of the
size of this PR.

---------

Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
2024-12-19 20:06:21 +00:00

70 lines
2.1 KiB
Dart

// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import '../base/logger.dart';
import '../convert.dart';
import '../ios/xcodeproj.dart';
import '../project.dart';
/// The type of analysis to perform.
enum IOSAnalyzeOption {
/// Prints out available build variants of the iOS Xcode sub-project.
///
/// An example output:
///
/// {"configurations":["Debug","Release","Profile"],"targets":["Runner","RunnerTests"]}
listBuildOptions,
/// Outputs universal link settings of the iOS Xcode sub-project into a file.
///
/// The file path will be printed after the command is run successfully.
outputUniversalLinkSettings,
}
/// Analyze the iOS Xcode sub-project of a Flutter project.
///
/// The [userPath] must be point to a flutter project.
class IOSAnalyze {
IOSAnalyze({
required this.project,
required this.option,
this.configuration,
this.target,
required this.logger,
}) : assert(
option == IOSAnalyzeOption.listBuildOptions || (configuration != null && target != null),
);
final FlutterProject project;
final IOSAnalyzeOption option;
final String? configuration;
final String? target;
final Logger logger;
Future<void> analyze() async {
switch (option) {
case IOSAnalyzeOption.listBuildOptions:
final XcodeProjectInfo? info = await project.ios.projectInfo();
final Map<String, List<String>> result;
if (info == null) {
result = const <String, List<String>>{};
} else {
result = <String, List<String>>{
'configurations': info.buildConfigurations,
'targets': info.targets,
};
}
logger.printStatus(jsonEncode(result));
case IOSAnalyzeOption.outputUniversalLinkSettings:
final String filePath = await project.ios.outputsUniversalLinkSettings(
configuration: configuration!,
target: target!,
);
logger.printStatus('result saved in $filePath');
}
}
}