add daemon command to enumerate supported platforms (#33472)
This commit is contained in:
parent
2cb5b24b02
commit
f38ee15286
@ -60,6 +60,17 @@ The `version()` command responds with a String with the protocol version.
|
|||||||
|
|
||||||
The `shutdown()` command will terminate the flutter daemon. It is not necessary to call this before shutting down the daemon; it is perfectly acceptable to just kill the daemon process.
|
The `shutdown()` command will terminate the flutter daemon. It is not necessary to call this before shutting down the daemon; it is perfectly acceptable to just kill the daemon process.
|
||||||
|
|
||||||
|
### daemon.getSupportedPlatforms
|
||||||
|
|
||||||
|
The `getSupportedPlatforms()` command will enumerate all platforms supported by the project located at the provided `projectRoot`. It returns a Map with the key 'platforms' containing a List of strings which describe the set of all possibly supported platforms. Possible values include:
|
||||||
|
- android
|
||||||
|
- ios
|
||||||
|
- linux #experimental
|
||||||
|
- macos #experimental
|
||||||
|
- windows #experimental
|
||||||
|
- fuchsia #experimental
|
||||||
|
- web #experimental
|
||||||
|
|
||||||
#### Events
|
#### Events
|
||||||
|
|
||||||
#### daemon.connected
|
#### daemon.connected
|
||||||
|
@ -248,6 +248,7 @@ class DaemonDomain extends Domain {
|
|||||||
DaemonDomain(Daemon daemon) : super(daemon, 'daemon') {
|
DaemonDomain(Daemon daemon) : super(daemon, 'daemon') {
|
||||||
registerHandler('version', version);
|
registerHandler('version', version);
|
||||||
registerHandler('shutdown', shutdown);
|
registerHandler('shutdown', shutdown);
|
||||||
|
registerHandler('getSupportedPlatforms', getSupportedPlatforms);
|
||||||
|
|
||||||
sendEvent(
|
sendEvent(
|
||||||
'daemon.connected',
|
'daemon.connected',
|
||||||
@ -300,6 +301,59 @@ class DaemonDomain extends Domain {
|
|||||||
void dispose() {
|
void dispose() {
|
||||||
_subscription?.cancel();
|
_subscription?.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Enumerates the platforms supported by the provided project.
|
||||||
|
///
|
||||||
|
/// This does not filter based on the current workflow restrictions, such
|
||||||
|
/// as whether command line tools are installed or whether the host platform
|
||||||
|
/// is correct.
|
||||||
|
Future<Map<String, Object>> getSupportedPlatforms(Map<String, dynamic> args) async {
|
||||||
|
final String projectRoot = _getStringArg(args, 'projectRoot', required: true);
|
||||||
|
final List<String> result = <String>[];
|
||||||
|
try {
|
||||||
|
// TODO(jonahwilliams): replace this with a project metadata check once
|
||||||
|
// that has been implemented.
|
||||||
|
final FlutterProject flutterProject = FlutterProject.fromDirectory(fs.directory(projectRoot));
|
||||||
|
if (flutterProject.linux.existsSync()) {
|
||||||
|
result.add('linux');
|
||||||
|
}
|
||||||
|
if (flutterProject.macos.existsSync()) {
|
||||||
|
result.add('macos');
|
||||||
|
}
|
||||||
|
if (flutterProject.windows.existsSync()) {
|
||||||
|
result.add('windows');
|
||||||
|
}
|
||||||
|
if (flutterProject.ios.existsSync()) {
|
||||||
|
result.add('ios');
|
||||||
|
}
|
||||||
|
if (flutterProject.android.existsSync()) {
|
||||||
|
result.add('android');
|
||||||
|
}
|
||||||
|
if (flutterProject.web.existsSync()) {
|
||||||
|
result.add('web');
|
||||||
|
}
|
||||||
|
if (flutterProject.fuchsia.existsSync()) {
|
||||||
|
result.add('fuchsia');
|
||||||
|
}
|
||||||
|
return <String, Object>{
|
||||||
|
'platforms': result,
|
||||||
|
};
|
||||||
|
} catch (err, stackTrace) {
|
||||||
|
sendEvent('log', <String, dynamic>{
|
||||||
|
'log': 'Failed to parse project metadata',
|
||||||
|
'stackTrace': stackTrace.toString(),
|
||||||
|
'error': true,
|
||||||
|
});
|
||||||
|
// On any sort of failure, fall back to Android and iOS for backwards
|
||||||
|
// comparability.
|
||||||
|
return <String, Object>{
|
||||||
|
'platforms': <String>[
|
||||||
|
'android',
|
||||||
|
'ios',
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef _RunOrAttach = Future<void> Function({
|
typedef _RunOrAttach = Future<void> Function({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user