Initialize Flutter Beta (flutter-3.32-candidate.0) (#166783)
Closes https://github.com/flutter/flutter/issues/166811. ```sh $ dev/conductor/bin/conductor start \ --candidate-branch=flutter-3.32-candidate.0 \ --release-channel=beta \ --github-username=matanlurey \ --dart-revision=0d6811928830b87e36a0f49eb7fe554c308d3699 ```
This commit is contained in:
@@ -258,8 +258,6 @@ List<FlutterCommand> generateCommands({required bool verboseHelp, required bool
|
||||
platform: globals.platform,
|
||||
shutdownHooks: globals.shutdownHooks,
|
||||
os: globals.os,
|
||||
processManager: globals.processManager,
|
||||
artifacts: globals.artifacts!,
|
||||
),
|
||||
UpgradeCommand(verboseHelp: verboseHelp),
|
||||
SymbolizeCommand(stdio: globals.stdio, fileSystem: globals.fs),
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
import 'package:args/args.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:package_config/package_config.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/common.dart';
|
||||
import '../base/deferred_component.dart';
|
||||
import '../base/file_system.dart';
|
||||
@@ -26,8 +24,6 @@ import '../linux/build_linux.dart';
|
||||
import '../macos/build_macos.dart';
|
||||
import '../project.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import '../runner/flutter_command_runner.dart';
|
||||
import '../widget_preview/dtd_services.dart';
|
||||
import '../widget_preview/preview_code_generator.dart';
|
||||
import '../widget_preview/preview_detector.dart';
|
||||
import '../widget_preview/preview_manifest.dart';
|
||||
@@ -45,8 +41,6 @@ class WidgetPreviewCommand extends FlutterCommand {
|
||||
required Platform platform,
|
||||
required ShutdownHooks shutdownHooks,
|
||||
required OperatingSystemUtils os,
|
||||
required ProcessManager processManager,
|
||||
required Artifacts artifacts,
|
||||
}) {
|
||||
addSubcommand(
|
||||
WidgetPreviewStartCommand(
|
||||
@@ -58,8 +52,6 @@ class WidgetPreviewCommand extends FlutterCommand {
|
||||
platform: platform,
|
||||
shutdownHooks: shutdownHooks,
|
||||
os: os,
|
||||
processManager: processManager,
|
||||
artifacts: artifacts,
|
||||
),
|
||||
);
|
||||
addSubcommand(
|
||||
@@ -126,8 +118,6 @@ final class WidgetPreviewStartCommand extends WidgetPreviewSubCommandBase with C
|
||||
required this.platform,
|
||||
required this.shutdownHooks,
|
||||
required this.os,
|
||||
required this.processManager,
|
||||
required this.artifacts,
|
||||
}) {
|
||||
addPubOptions();
|
||||
argParser
|
||||
@@ -162,9 +152,6 @@ final class WidgetPreviewStartCommand extends WidgetPreviewSubCommandBase with C
|
||||
static const String kHeadlessWeb = 'headless-web';
|
||||
static const String kWidgetPreviewScaffoldOutputDir = 'scaffold-output-dir';
|
||||
|
||||
/// Environment variable used to pass the DTD URI to the widget preview scaffold.
|
||||
static const String kWidgetPreviewDtdUriEnvVar = 'WIDGET_PREVIEW_DTD_URI';
|
||||
|
||||
@override
|
||||
Future<Set<DevelopmentArtifact>> get requiredArtifacts async => const <DevelopmentArtifact>{
|
||||
// Ensure the Flutter Web SDK is installed.
|
||||
@@ -198,10 +185,6 @@ final class WidgetPreviewStartCommand extends WidgetPreviewSubCommandBase with C
|
||||
|
||||
final OperatingSystemUtils os;
|
||||
|
||||
final ProcessManager processManager;
|
||||
|
||||
final Artifacts artifacts;
|
||||
|
||||
late final FlutterProject rootProject = getRootProject();
|
||||
|
||||
late final PreviewDetector _previewDetector = PreviewDetector(
|
||||
@@ -220,12 +203,6 @@ final class WidgetPreviewStartCommand extends WidgetPreviewSubCommandBase with C
|
||||
cache: cache,
|
||||
);
|
||||
|
||||
late final WidgetPreviewDtdServices _dtdService = WidgetPreviewDtdServices(
|
||||
logger: logger,
|
||||
shutdownHooks: shutdownHooks,
|
||||
dtdLauncher: DtdLauncher(logger: logger, artifacts: artifacts, processManager: processManager),
|
||||
);
|
||||
|
||||
/// The currently running instance of the widget preview scaffold.
|
||||
AppInstance? _widgetPreviewApp;
|
||||
|
||||
@@ -307,7 +284,6 @@ final class WidgetPreviewStartCommand extends WidgetPreviewSubCommandBase with C
|
||||
shutdownHooks.addShutdownHook(() async {
|
||||
await _widgetPreviewApp?.stop();
|
||||
});
|
||||
await configureDtd();
|
||||
_widgetPreviewApp = await runPreviewEnvironment(
|
||||
widgetPreviewScaffoldProject: rootProject.widgetPreviewScaffoldProject,
|
||||
);
|
||||
@@ -333,31 +309,6 @@ final class WidgetPreviewStartCommand extends WidgetPreviewSubCommandBase with C
|
||||
_populatePreviewPubspec(rootProject: rootProject);
|
||||
}
|
||||
|
||||
/// Configures the Dart Tooling Daemon connection.
|
||||
///
|
||||
/// If --dtd-uri is provided, the existing DTD instance will be used. If the tool fails to
|
||||
/// connect to this URI, it will start its own DTD instance.
|
||||
///
|
||||
/// If --dtd-uri is not provided, a DTD instance managed by the tool will be started.
|
||||
Future<void> configureDtd() async {
|
||||
final String? existingDtdUriStr = stringArg(FlutterGlobalOptions.kDtdUrl, global: true);
|
||||
Uri? existingDtdUri;
|
||||
try {
|
||||
if (existingDtdUriStr != null) {
|
||||
existingDtdUri = Uri.parse(existingDtdUriStr);
|
||||
}
|
||||
} on FormatException {
|
||||
logger.printWarning('Failed to parse value of --dtd-uri: $existingDtdUriStr.');
|
||||
}
|
||||
if (existingDtdUri == null) {
|
||||
logger.printTrace('Launching a fresh DTD instance...');
|
||||
await _dtdService.launchAndConnect();
|
||||
} else {
|
||||
logger.printTrace('Connecting to existing DTD instance at: $existingDtdUri...');
|
||||
await _dtdService.connect(dtdWsUri: existingDtdUri);
|
||||
}
|
||||
}
|
||||
|
||||
/// Builds the application binary for the widget preview scaffold the first
|
||||
/// time the widget preview command is run.
|
||||
///
|
||||
@@ -506,12 +457,6 @@ final class WidgetPreviewStartCommand extends WidgetPreviewSubCommandBase with C
|
||||
BuildMode.debug,
|
||||
null,
|
||||
treeShakeIcons: false,
|
||||
// Provide the DTD connection information directly to the preview scaffold.
|
||||
// This could, in theory, be provided via a follow up call to a service extension
|
||||
// registered by the preview scaffold, but there's some uncertainty around how service
|
||||
// extensions will work with Flutter web embedded in VSCode without a Chrome debugger
|
||||
// connection.
|
||||
dartDefines: <String>['$kWidgetPreviewDtdUriEnvVar=${_dtdService.dtdUri}'],
|
||||
extraFrontEndOptions:
|
||||
isWeb ? <String>['--dartdevc-canary', '--dartdevc-module-format=ddc'] : null,
|
||||
packageConfigPath: widgetPreviewScaffoldProject.packageConfig.path,
|
||||
@@ -654,7 +599,6 @@ final class WidgetPreviewStartCommand extends WidgetPreviewSubCommandBase with C
|
||||
if (offline) '--offline',
|
||||
'--directory',
|
||||
widgetPreviewScaffoldProject.directory.path,
|
||||
'dtd',
|
||||
'flutter_lints',
|
||||
'stack_trace',
|
||||
],
|
||||
|
||||
@@ -18,7 +18,13 @@ Future<Set<String>> computeExclusiveDevDependencies(
|
||||
required Logger logger,
|
||||
required FlutterProject project,
|
||||
}) async {
|
||||
final Map<String, Object?> jsonResult = await pub.deps(project);
|
||||
final Map<String, Object?>? jsonResult = await pub.deps(project);
|
||||
|
||||
// Avoid crashing if dart pub deps is not ready.
|
||||
// See https://github.com/flutter/flutter/issues/166648.
|
||||
if (jsonResult == null) {
|
||||
return <String>{};
|
||||
}
|
||||
|
||||
Never fail([String? reason]) {
|
||||
logger.printTrace(const JsonEncoder.withIndent(' ').convert(jsonResult));
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../application_package.dart';
|
||||
import '../artifacts.dart';
|
||||
import '../base/common.dart';
|
||||
import '../base/file_system.dart';
|
||||
import '../base/io.dart';
|
||||
@@ -21,6 +22,7 @@ import '../convert.dart';
|
||||
import '../device.dart';
|
||||
import '../device_port_forwarder.dart';
|
||||
import '../features.dart';
|
||||
import '../globals.dart' as globals;
|
||||
import '../project.dart';
|
||||
import '../protocol_discovery.dart';
|
||||
import '../vmservice.dart';
|
||||
@@ -341,6 +343,7 @@ class CustomDeviceAppSession {
|
||||
Map<String, Object?> platformArgs = const <String, Object>{},
|
||||
bool prebuiltApplication = false,
|
||||
String? userIdentifier,
|
||||
Map<String, String> additionalReplacementValues = const <String, String>{},
|
||||
}) async {
|
||||
final bool traceStartup = platformArgs['trace-startup'] as bool? ?? false;
|
||||
final String? packageName = _appPackage.name;
|
||||
@@ -352,7 +355,7 @@ class CustomDeviceAppSession {
|
||||
'remotePath': '/tmp/',
|
||||
'appName': packageName,
|
||||
'engineOptions': _getEngineOptionsForCmdline(debuggingOptions, traceStartup, route),
|
||||
});
|
||||
}, additionalReplacementValues: additionalReplacementValues);
|
||||
|
||||
final Process process = await _processUtils.start(interpolated);
|
||||
assert(_process == null);
|
||||
@@ -700,6 +703,16 @@ class CustomDevice extends Device {
|
||||
String? userIdentifier,
|
||||
BundleBuilder? bundleBuilder,
|
||||
}) async {
|
||||
final TargetPlatform platform = await targetPlatform;
|
||||
final Artifacts artifacts = globals.artifacts!;
|
||||
|
||||
final Map<String, String> additionalReplacementValues = <String, String>{
|
||||
'buildMode': debuggingOptions.buildInfo.modeName,
|
||||
'icuDataPath': artifacts.getArtifactPath(Artifact.icuData, platform: platform),
|
||||
'engineRevision':
|
||||
artifacts.usesLocalArtifacts ? 'local' : globals.flutterVersion.engineRevision,
|
||||
};
|
||||
|
||||
if (!prebuiltApplication) {
|
||||
final String assetBundleDir = getAssetBuildDirectory();
|
||||
|
||||
@@ -707,7 +720,7 @@ class CustomDevice extends Device {
|
||||
|
||||
// this just builds the asset bundle, it's the same as `flutter build bundle`
|
||||
await bundleBuilder.build(
|
||||
platform: await targetPlatform,
|
||||
platform: platform,
|
||||
buildInfo: debuggingOptions.buildInfo,
|
||||
mainPath: mainPath,
|
||||
depfilePath: defaultDepfilePath,
|
||||
@@ -720,7 +733,11 @@ class CustomDevice extends Device {
|
||||
if (packageName == null) {
|
||||
throwToolExit('Could not start app, name for $package is unknown.');
|
||||
}
|
||||
await _tryPostBuild(appName: packageName, localPath: assetBundleDir);
|
||||
await _tryPostBuild(
|
||||
appName: packageName,
|
||||
localPath: assetBundleDir,
|
||||
additionalReplacementValues: additionalReplacementValues,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -736,6 +753,7 @@ class CustomDevice extends Device {
|
||||
platformArgs: platformArgs,
|
||||
prebuiltApplication: prebuiltApplication,
|
||||
userIdentifier: userIdentifier,
|
||||
additionalReplacementValues: additionalReplacementValues,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +158,9 @@ abstract class Pub {
|
||||
/// While it is guaranteed that, if successful, that the result are a valid
|
||||
/// JSON object, the exact contents returned are _not_ validated, and are left
|
||||
/// as a responsibility of the caller.
|
||||
Future<Map<String, Object?>> deps(FlutterProject project);
|
||||
///
|
||||
/// If `null` is returned, it should be assumed deps could not be determined.
|
||||
Future<Map<String, Object?>?> deps(FlutterProject project);
|
||||
|
||||
/// Runs pub in 'batch' mode.
|
||||
///
|
||||
@@ -354,13 +356,22 @@ class _DefaultPub implements Pub {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, Object?>> deps(FlutterProject project) async {
|
||||
Future<Map<String, Object?>?> deps(FlutterProject project) async {
|
||||
final List<String> pubCommand = <String>[..._pubCommand, 'deps', '--json'];
|
||||
final RunResult runResult;
|
||||
|
||||
final RunResult runResult = await _processUtils.run(
|
||||
pubCommand,
|
||||
workingDirectory: project.directory.path,
|
||||
);
|
||||
// Don't treat this command as terminal if it fails.
|
||||
// See https://github.com/flutter/flutter/issues/166648
|
||||
try {
|
||||
runResult = await _processUtils.run(
|
||||
pubCommand,
|
||||
workingDirectory: project.directory.path,
|
||||
throwOnError: true,
|
||||
);
|
||||
} on io.ProcessException catch (e) {
|
||||
_logger.printWarning('${pubCommand.join(' ')} ${e.message}');
|
||||
return null;
|
||||
}
|
||||
|
||||
Never fail([String? reason]) {
|
||||
final String stdout = runResult.stdout;
|
||||
@@ -374,11 +385,6 @@ class _DefaultPub implements Pub {
|
||||
);
|
||||
}
|
||||
|
||||
// Guard against dart pub deps crashing.
|
||||
if (runResult.exitCode != 0) {
|
||||
fail();
|
||||
}
|
||||
|
||||
// Guard against dart pub deps having explicitly invalid output.
|
||||
try {
|
||||
final Object? result = json.decode(runResult.stdout);
|
||||
|
||||
@@ -36,7 +36,6 @@ abstract final class FlutterGlobalOptions {
|
||||
static const String kMachineFlag = 'machine';
|
||||
static const String kPackagesOption = 'packages';
|
||||
static const String kPrefixedErrorsFlag = 'prefixed-errors';
|
||||
static const String kDtdUrl = 'dtd-url';
|
||||
static const String kPrintDtd = 'print-dtd';
|
||||
static const String kQuietFlag = 'quiet';
|
||||
static const String kShowTestDeviceFlag = 'show-test-device';
|
||||
@@ -152,12 +151,6 @@ class FlutterCommandRunner extends CommandRunner<void> {
|
||||
hide: !verboseHelp,
|
||||
help: 'Path to your "package_config.json" file.',
|
||||
);
|
||||
argParser.addOption(
|
||||
FlutterGlobalOptions.kDtdUrl,
|
||||
help:
|
||||
'The address of an existing Dart Tooling Daemon instance to be used by the Flutter CLI.',
|
||||
hide: !verboseHelp,
|
||||
);
|
||||
argParser.addFlag(
|
||||
FlutterGlobalOptions.kPrintDtd,
|
||||
negatable: false,
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
// 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 'package:dtd/dtd.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../base/common.dart';
|
||||
import '../base/io.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/process.dart';
|
||||
import '../convert.dart';
|
||||
|
||||
/// Provides services, streams, and RPC invocations to interact with the Widget Preview Scaffold.
|
||||
class WidgetPreviewDtdServices {
|
||||
WidgetPreviewDtdServices({
|
||||
required this.logger,
|
||||
required this.shutdownHooks,
|
||||
required this.dtdLauncher,
|
||||
}) {
|
||||
shutdownHooks.addShutdownHook(() async {
|
||||
await _dtd?.close();
|
||||
await dtdLauncher.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
final Logger logger;
|
||||
final ShutdownHooks shutdownHooks;
|
||||
final DtdLauncher dtdLauncher;
|
||||
|
||||
DartToolingDaemon? _dtd;
|
||||
|
||||
/// The [Uri] pointing to the currently connected DTD instance.
|
||||
///
|
||||
/// Returns `null` if there is no DTD connection.
|
||||
Uri? get dtdUri => _dtdUri;
|
||||
Uri? _dtdUri;
|
||||
|
||||
/// Starts DTD in a child process before invoking [connect] with a [Uri] pointing to the new
|
||||
/// DTD instance.
|
||||
Future<void> launchAndConnect() async {
|
||||
// Connect to the new DTD instance.
|
||||
await connect(dtdWsUri: await dtdLauncher.launch());
|
||||
}
|
||||
|
||||
/// Connects to an existing DTD instance and registers any relevant services.
|
||||
Future<void> connect({required Uri dtdWsUri}) async {
|
||||
_dtdUri = dtdWsUri;
|
||||
_dtd = await DartToolingDaemon.connect(dtdWsUri);
|
||||
// TODO(bkonyi): register services.
|
||||
logger.printTrace('Connected to DTD and registered services.');
|
||||
}
|
||||
}
|
||||
|
||||
/// Manages the lifecycle of a Dart Tooling Daemon (DTD) instance.
|
||||
class DtdLauncher {
|
||||
DtdLauncher({required this.logger, required this.artifacts, required this.processManager});
|
||||
|
||||
/// Starts a new DTD instance and returns the web socket URI it's available on.
|
||||
Future<Uri> launch() async {
|
||||
if (_dtdProcess != null) {
|
||||
throw StateError('Attempted to launch DTD twice.');
|
||||
}
|
||||
|
||||
// Start DTD.
|
||||
_dtdProcess = await processManager.start(<Object>[
|
||||
artifacts.getArtifactPath(Artifact.engineDartBinary),
|
||||
'tooling-daemon',
|
||||
'--machine',
|
||||
]);
|
||||
|
||||
// Wait for the DTD connection information.
|
||||
final Completer<Uri> dtdUri = Completer<Uri>();
|
||||
late final StreamSubscription<String> sub;
|
||||
sub = _dtdProcess!.stdout.transform(const Utf8Decoder()).listen((String data) async {
|
||||
await sub.cancel();
|
||||
final Map<String, Object?> jsonData = json.decode(data) as Map<String, Object?>;
|
||||
if (jsonData case {'tooling_daemon_details': {'uri': final String dtdUriString}}) {
|
||||
dtdUri.complete(Uri.parse(dtdUriString));
|
||||
} else {
|
||||
throwToolExit('Unable to start the Dart Tooling Daemon.');
|
||||
}
|
||||
});
|
||||
return dtdUri.future;
|
||||
}
|
||||
|
||||
/// Kills the spawned DTD instance.
|
||||
Future<void> dispose() async {
|
||||
_dtdProcess?.kill();
|
||||
_dtdProcess = null;
|
||||
}
|
||||
|
||||
final Logger logger;
|
||||
final Artifacts artifacts;
|
||||
final ProcessManager processManager;
|
||||
|
||||
Process? _dtdProcess;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ dependencies:
|
||||
ffi: 2.1.4
|
||||
file: 7.0.1
|
||||
flutter_template_images: 5.0.0
|
||||
html: 0.15.5
|
||||
html: 0.15.5+1
|
||||
http: 1.3.0
|
||||
intl: 0.20.2
|
||||
meta: 1.16.0
|
||||
@@ -122,4 +122,4 @@ dartdoc:
|
||||
# Exclude this package from the hosted API docs.
|
||||
nodoc: true
|
||||
|
||||
# PUBSPEC CHECKSUM: fe37
|
||||
# PUBSPEC CHECKSUM: c093
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
"required": false
|
||||
},
|
||||
"postBuild": {
|
||||
"description": "The command to be invoked after the build process is done, to do any additional packaging for example.",
|
||||
"description": "The command to be invoked after the build process is done, to do any additional packaging for example. The following variables are available via string interpolation:\n- ${appName}\n- ${localPath}\n- ${buildMode}\n- ${icuDataPath}\n- ${engineRevision}",
|
||||
"type": ["array", "null"],
|
||||
"items": {
|
||||
"type": "string"
|
||||
@@ -91,7 +91,7 @@
|
||||
]
|
||||
},
|
||||
"runDebug": {
|
||||
"description": "The command to be invoked to run the app in debug mode. The name of the app to be started is available via the ${appName} string interpolation. Make sure the flutter cmdline output is available via this commands stdout/stderr since the SDK needs the \"VM Service is now listening on ...\" message to function. If the forwardPort command is not specified, the VM Service URL will be connected to as-is, without any port forwarding. In that case you need to make sure it is reachable from your host device, possibly via the \"--vm-service-host=<ip>\" engine flag.",
|
||||
"description": "The command to be invoked to run the app in debug mode. Make sure the flutter cmdline output is available via this commands stdout/stderr since the SDK needs the \"VM Service is now listening on ...\" message to function. If the forwardPort command is not specified, the VM Service URL will be connected to as-is, without any port forwarding. In that case you need to make sure it is reachable from your host device, possibly via the \"--vm-service-host=<ip>\" engine flag. The following variables are available via string interpolation:\n- ${appName}\n- ${engineOptions}\n- ${buildMode}\n- ${icuDataPath}\n- ${engineRevision}",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
|
||||
@@ -356,7 +356,6 @@
|
||||
"templates/widget_preview_scaffold/lib/src/widget_preview.dart.tmpl",
|
||||
"templates/widget_preview_scaffold/lib/src/widget_preview_rendering.dart.tmpl",
|
||||
"templates/widget_preview_scaffold/lib/src/controls.dart.tmpl",
|
||||
"templates/widget_preview_scaffold/lib/src/dtd_services.dart.tmpl",
|
||||
"templates/widget_preview_scaffold/lib/src/generated_preview.dart.tmpl",
|
||||
"templates/widget_preview_scaffold/lib/src/utils.dart.tmpl",
|
||||
"templates/widget_preview_scaffold/pubspec.yaml.tmpl",
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
// 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 'package:dtd/dtd.dart';
|
||||
|
||||
/// Provides services, streams, and RPC invocations to interact with Flutter developer tooling.
|
||||
class WidgetPreviewScaffoldDtdServices {
|
||||
/// Environment variable for the DTD URI.
|
||||
static const String kWidgetPreviewDtdUriEnvVar = 'WIDGET_PREVIEW_DTD_URI';
|
||||
|
||||
/// Connects to the Dart Tooling Daemon (DTD) specified by the Flutter tool.
|
||||
///
|
||||
/// If the connection is successful, the Widget Preview Scaffold will register services and
|
||||
/// subscribe to various streams to interact directly with other tooling (e.g., IDEs).
|
||||
Future<void> connect() async {
|
||||
final Uri dtdWsUri = Uri.parse(
|
||||
const String.fromEnvironment(kWidgetPreviewDtdUriEnvVar),
|
||||
);
|
||||
_dtd = await DartToolingDaemon.connect(dtdWsUri);
|
||||
unawaited(
|
||||
_dtd.postEvent(
|
||||
'WidgetPreviewScaffold',
|
||||
'Connected',
|
||||
const <String, Object?>{},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
late final DartToolingDaemon _dtd;
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import 'package:flutter/services.dart';
|
||||
import 'package:stack_trace/stack_trace.dart';
|
||||
|
||||
import 'controls.dart';
|
||||
import 'dtd_services.dart';
|
||||
import 'generated_preview.dart';
|
||||
import 'utils.dart';
|
||||
import 'widget_preview.dart';
|
||||
@@ -411,8 +410,6 @@ class PreviewAssetBundle extends PlatformAssetBundle {
|
||||
/// the preview scaffold project which prevents us from being able to use hot
|
||||
/// restart to iterate on this file.
|
||||
Future<void> mainImpl() async {
|
||||
// TODO(bkonyi): store somewhere.
|
||||
await WidgetPreviewScaffoldDtdServices().connect();
|
||||
runApp(_WidgetPreviewScaffold());
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
# These will be replaced with proper constraints after the template is hydrated.
|
||||
dtd: any
|
||||
flutter_lints: any
|
||||
stack_trace: any
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/base/os.dart';
|
||||
@@ -48,8 +47,6 @@ void main() {
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
),
|
||||
processManager: FakeProcessManager.any(),
|
||||
artifacts: Artifacts.test(fileSystem: fileSystem),
|
||||
);
|
||||
rootProject = FakeFlutterProject(
|
||||
projectRoot: 'some_project',
|
||||
|
||||
@@ -6,7 +6,6 @@ import 'dart:io' as io show IOOverrides;
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/base/bot_detector.dart';
|
||||
import 'package:flutter_tools/src/base/common.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
@@ -81,8 +80,6 @@ void main() {
|
||||
logger: logger,
|
||||
platform: platform,
|
||||
),
|
||||
artifacts: Artifacts.test(),
|
||||
processManager: FakeProcessManager.any(),
|
||||
),
|
||||
);
|
||||
await runner.run(<String>['widget-preview', ...arguments]);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:io' as io;
|
||||
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
@@ -356,6 +358,17 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test('a pub error is treated as no data available instead of terminal', () async {
|
||||
final ProcessManager processes = _dartPubDepsCrashes(project: project);
|
||||
final Set<String> dependencies = await computeExclusiveDevDependencies(
|
||||
pub(processes),
|
||||
project: project,
|
||||
logger: logger,
|
||||
);
|
||||
|
||||
expect(dependencies, isEmpty, reason: 'pub deps crashed, but was not terminal');
|
||||
});
|
||||
|
||||
test('throws and logs on invalid JSON', () async {
|
||||
final ProcessManager processes = _dartPubDepsReturns('''
|
||||
{
|
||||
@@ -420,3 +433,18 @@ ProcessManager _dartPubDepsReturns(String dartPubDepsOutput, {required FlutterPr
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
ProcessManager _dartPubDepsCrashes({required FlutterProject project}) {
|
||||
return FakeProcessManager.list(<FakeCommand>[
|
||||
FakeCommand(
|
||||
command: const <String>[_dartBin, 'pub', '--suppress-analytics', 'deps', '--json'],
|
||||
workingDirectory: project.directory.path,
|
||||
exception: const io.ProcessException('pub', <String>[
|
||||
'pub',
|
||||
'--suppress-analytics',
|
||||
'deps',
|
||||
'--json',
|
||||
]),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'dart:async';
|
||||
import 'package:file/file.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:file_testing/file_testing.dart';
|
||||
import 'package:flutter_tools/src/artifacts.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/build_info.dart';
|
||||
import 'package:flutter_tools/src/build_system/build_system.dart';
|
||||
@@ -530,6 +531,100 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testUsingContext(
|
||||
'custom device command string interpolation end-to-end test',
|
||||
() async {
|
||||
final Completer<void> runDebugCompleter = Completer<void>();
|
||||
|
||||
final CustomDeviceConfig config = testConfig.copyWith(
|
||||
platform: TargetPlatform.linux_arm64,
|
||||
postBuildCommand: const <String>[
|
||||
'testpostbuild',
|
||||
r'--buildMode=${buildMode}',
|
||||
r'--icuDataPath=${icuDataPath}',
|
||||
r'--engineRevision=${engineRevision}',
|
||||
],
|
||||
runDebugCommand: const <String>[
|
||||
'testrundebug',
|
||||
r'--buildMode=${buildMode}',
|
||||
r'--icuDataPath=${icuDataPath}',
|
||||
r'--engineRevision=${engineRevision}',
|
||||
],
|
||||
);
|
||||
|
||||
final List<Pattern> commandArgumentsPattern = <Pattern>[
|
||||
RegExp(r'--buildMode=.*'),
|
||||
RegExp(r'--icuDataPath=.*'),
|
||||
RegExp(r'--engineRevision=.*'),
|
||||
];
|
||||
|
||||
final String expectedIcuDataPath = globals.artifacts!.getArtifactPath(
|
||||
Artifact.icuData,
|
||||
platform: config.platform,
|
||||
);
|
||||
final String expectedEngineRevision = globals.flutterVersion.engineRevision;
|
||||
|
||||
final List<String> expectedCommandArguments = <String>[
|
||||
'--buildMode=debug',
|
||||
'--icuDataPath=$expectedIcuDataPath',
|
||||
'--engineRevision=$expectedEngineRevision',
|
||||
];
|
||||
|
||||
final List<String> expectedRunDebugCommand = <String>[
|
||||
'testrundebug',
|
||||
...expectedCommandArguments,
|
||||
];
|
||||
final List<String> expectedPostBuildCommand = <String>[
|
||||
'testpostbuild',
|
||||
...expectedCommandArguments,
|
||||
];
|
||||
|
||||
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
|
||||
FakeCommand(
|
||||
command: <Pattern>['testpostbuild', ...commandArgumentsPattern],
|
||||
onRun: (List<String> command) => expect(command, expectedPostBuildCommand),
|
||||
),
|
||||
FakeCommand(command: config.uninstallCommand),
|
||||
FakeCommand(command: config.installCommand),
|
||||
FakeCommand(
|
||||
command: <Pattern>['testrundebug', ...commandArgumentsPattern],
|
||||
completer: runDebugCompleter,
|
||||
onRun: (List<String> command) => expect(command, expectedRunDebugCommand),
|
||||
stdout: 'The Dart VM service is listening on http://127.0.0.1:12345/abcd/\n',
|
||||
),
|
||||
FakeCommand(
|
||||
command: config.forwardPortCommand!,
|
||||
stdout: testConfigForwardPortSuccessOutput,
|
||||
),
|
||||
]);
|
||||
|
||||
// CustomDevice.startApp doesn't care whether we pass a prebuilt app or
|
||||
// buildable app as long as we pass prebuiltApplication as false
|
||||
final PrebuiltLinuxApp app = PrebuiltLinuxApp(executable: 'testexecutable');
|
||||
|
||||
// finally start actually testing things
|
||||
final CustomDevice device = CustomDevice(
|
||||
config: config,
|
||||
logger: BufferLogger.test(),
|
||||
processManager: processManager,
|
||||
);
|
||||
|
||||
await device.startApp(
|
||||
app,
|
||||
debuggingOptions: DebuggingOptions.enabled(BuildInfo.debug),
|
||||
bundleBuilder: FakeBundleBuilder(),
|
||||
);
|
||||
expect(runDebugCompleter.isCompleted, false);
|
||||
|
||||
expect(await device.stopApp(app), true);
|
||||
expect(runDebugCompleter.isCompleted, true);
|
||||
},
|
||||
overrides: <Type, Generator>{
|
||||
FileSystem: () => MemoryFileSystem.test(),
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
},
|
||||
);
|
||||
|
||||
testWithoutContext('CustomDevice screenshotting', () async {
|
||||
bool screenshotCommandWasExecuted = false;
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWithoutContext('fails on non-zero exit code', () async {
|
||||
testWithoutContext('returns null on non-zero exit code', () async {
|
||||
final BufferLogger logger = BufferLogger.test();
|
||||
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
||||
final ProcessManager processManager = _dartPubDepsFails(
|
||||
@@ -62,14 +62,8 @@ void main() {
|
||||
);
|
||||
|
||||
await expectLater(
|
||||
() => pub.deps(FlutterProject.fromDirectoryTest(fileSystem.currentDirectory)),
|
||||
throwsA(
|
||||
isA<StateError>().having(
|
||||
(StateError e) => e.message,
|
||||
'message',
|
||||
contains('dart pub --suppress-analytics deps --json failed'),
|
||||
),
|
||||
),
|
||||
pub.deps(FlutterProject.fromDirectoryTest(fileSystem.currentDirectory)),
|
||||
completion(isNull),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -5,18 +5,12 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dtd/dtd.dart';
|
||||
import 'package:file/file.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/logger.dart';
|
||||
import 'package:flutter_tools/src/commands/widget_preview.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
import 'package:flutter_tools/src/runner/flutter_command_runner.dart';
|
||||
import 'package:flutter_tools/src/widget_preview/dtd_services.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import '../src/common.dart';
|
||||
import '../src/context.dart';
|
||||
import 'test_data/basic_project.dart';
|
||||
import 'test_utils.dart';
|
||||
|
||||
@@ -49,13 +43,10 @@ const List<String> subsequentLaunchMessagesWeb = <String>[
|
||||
void main() {
|
||||
late Directory tempDir;
|
||||
Process? process;
|
||||
Logger? logger;
|
||||
DtdLauncher? dtdLauncher;
|
||||
final BasicProject project = BasicProject();
|
||||
const ProcessManager processManager = LocalProcessManager();
|
||||
|
||||
setUp(() async {
|
||||
logger = BufferLogger.test();
|
||||
tempDir = createResolvedTempDirectorySync('widget_preview_test.');
|
||||
await project.setUpIn(tempDir);
|
||||
});
|
||||
@@ -63,15 +54,12 @@ void main() {
|
||||
tearDown(() async {
|
||||
process?.kill();
|
||||
process = null;
|
||||
await dtdLauncher?.dispose();
|
||||
dtdLauncher = null;
|
||||
tryToDelete(tempDir);
|
||||
});
|
||||
|
||||
Future<void> runWidgetPreview({
|
||||
required List<String> expectedMessages,
|
||||
bool useWeb = false,
|
||||
Uri? dtdUri,
|
||||
}) async {
|
||||
expect(expectedMessages, isNotEmpty);
|
||||
int i = 0;
|
||||
@@ -84,7 +72,6 @@ void main() {
|
||||
'--${WidgetPreviewStartCommand.kHeadlessWeb}'
|
||||
else
|
||||
'--${WidgetPreviewStartCommand.kUseFlutterDesktop}',
|
||||
if (dtdUri != null) '--${FlutterGlobalOptions.kDtdUrl}=$dtdUri',
|
||||
], workingDirectory: tempDir.path);
|
||||
|
||||
final Completer<void> completer = Completer<void>();
|
||||
@@ -116,6 +103,8 @@ void main() {
|
||||
}),
|
||||
);
|
||||
await completer.future;
|
||||
process!.kill();
|
||||
process = null;
|
||||
}
|
||||
|
||||
group('flutter widget-preview start', () {
|
||||
@@ -143,38 +132,5 @@ void main() {
|
||||
// We shouldn't regenerate the scaffold after the initial run.
|
||||
await runWidgetPreview(expectedMessages: subsequentLaunchMessagesWeb, useWeb: true);
|
||||
});
|
||||
|
||||
testUsingContext('can connect to an existing DTD instance', () async {
|
||||
dtdLauncher = DtdLauncher(
|
||||
logger: logger!,
|
||||
artifacts: globals.artifacts!,
|
||||
processManager: globals.processManager,
|
||||
);
|
||||
|
||||
// Start a DTD instance.
|
||||
final Uri dtdUri = await dtdLauncher!.launch();
|
||||
|
||||
// Connect to it and listen to the WidgetPreviewScaffold stream.
|
||||
//
|
||||
// The preview scaffold will send a 'Connected' event on this stream once it has initialized
|
||||
// and is ready.
|
||||
final DartToolingDaemon dtdConnection = await DartToolingDaemon.connect(dtdUri);
|
||||
const String kWidgetPreviewScaffoldStream = 'WidgetPreviewScaffold';
|
||||
final Completer<void> completer = Completer<void>();
|
||||
dtdConnection.onEvent(kWidgetPreviewScaffoldStream).listen((DTDEvent event) {
|
||||
expect(event.stream, kWidgetPreviewScaffoldStream);
|
||||
expect(event.kind, 'Connected');
|
||||
completer.complete();
|
||||
});
|
||||
await dtdConnection.streamListen(kWidgetPreviewScaffoldStream);
|
||||
|
||||
// Start the widget preview and wait for the 'Connected' event.
|
||||
await runWidgetPreview(
|
||||
expectedMessages: firstLaunchMessagesWeb,
|
||||
useWeb: true,
|
||||
dtdUri: dtdUri,
|
||||
);
|
||||
await completer.future;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
// 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 'package:dtd/dtd.dart';
|
||||
|
||||
/// Provides services, streams, and RPC invocations to interact with Flutter developer tooling.
|
||||
class WidgetPreviewScaffoldDtdServices {
|
||||
/// Environment variable for the DTD URI.
|
||||
static const String kWidgetPreviewDtdUriEnvVar = 'WIDGET_PREVIEW_DTD_URI';
|
||||
|
||||
/// Connects to the Dart Tooling Daemon (DTD) specified by the Flutter tool.
|
||||
///
|
||||
/// If the connection is successful, the Widget Preview Scaffold will register services and
|
||||
/// subscribe to various streams to interact directly with other tooling (e.g., IDEs).
|
||||
Future<void> connect() async {
|
||||
final Uri dtdWsUri = Uri.parse(
|
||||
const String.fromEnvironment(kWidgetPreviewDtdUriEnvVar),
|
||||
);
|
||||
_dtd = await DartToolingDaemon.connect(dtdWsUri);
|
||||
unawaited(
|
||||
_dtd.postEvent(
|
||||
'WidgetPreviewScaffold',
|
||||
'Connected',
|
||||
const <String, Object?>{},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
late final DartToolingDaemon _dtd;
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import 'package:flutter/services.dart';
|
||||
import 'package:stack_trace/stack_trace.dart';
|
||||
|
||||
import 'controls.dart';
|
||||
import 'dtd_services.dart';
|
||||
import 'generated_preview.dart';
|
||||
import 'utils.dart';
|
||||
import 'widget_preview.dart';
|
||||
@@ -411,8 +410,6 @@ class PreviewAssetBundle extends PlatformAssetBundle {
|
||||
/// the preview scaffold project which prevents us from being able to use hot
|
||||
/// restart to iterate on this file.
|
||||
Future<void> mainImpl() async {
|
||||
// TODO(bkonyi): store somewhere.
|
||||
await WidgetPreviewScaffoldDtdServices().connect();
|
||||
runApp(_WidgetPreviewScaffold());
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
# These will be replaced with proper constraints after the template is hydrated.
|
||||
dtd: 2.5.0
|
||||
flutter_lints: 5.0.0
|
||||
stack_trace: 1.12.1
|
||||
|
||||
@@ -21,13 +20,7 @@ dependencies:
|
||||
characters: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
clock: 1.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
collection: 1.19.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
convert: 3.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
crypto: 3.0.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
fake_async: 1.3.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
file: 7.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
http: 1.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
http_parser: 4.1.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
json_rpc_2: 3.0.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
leak_tracker: 10.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
leak_tracker_flutter_testing: 3.0.9 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
leak_tracker_testing: 3.0.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
@@ -41,15 +34,10 @@ dependencies:
|
||||
string_scanner: 1.4.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
term_glyph: 1.2.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
test_api: 0.7.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
typed_data: 1.4.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
unified_analytics: 7.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
vector_math: 2.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
vm_service: 15.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
web: 1.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
web_socket: 0.1.6 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
web_socket_channel: 3.0.2 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
|
||||
# PUBSPEC CHECKSUM: 4b12
|
||||
# PUBSPEC CHECKSUM: 367e
|
||||
|
||||
Reference in New Issue
Block a user