Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fluttium_cli): add web port argument #418

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ Multiple defines can be passed by repeating "--dart-define" multiple times.''',
'compact': 'A single line that updates dynamically.',
'pretty': 'A nicely formatted output that works nicely with --watch.',
},
)
..addOption(
'web-port',
help:
'''The port number for serving the web application. Must be between 1024 and 65535. Defaults to null if not provided.''',
);
}

Expand Down Expand Up @@ -128,6 +133,8 @@ Multiple defines can be passed by repeating "--dart-define" multiple times.''',

List<String> get _dartDefines => results['dart-define'] as List<String>;

String? get _webPort => results['web-port'] as String?;

/// The file of the flow to run.
File get _userFlowFile {
if (results.rest.isEmpty || results.rest.first.isEmpty) {
Expand Down Expand Up @@ -294,6 +301,7 @@ Either adjust the constraint in the Fluttium configuration or update the CLI to
flavor: _flavor,
dartDefines: [...fluttium.driver.dartDefines, ..._dartDefines],
deviceId: results['device-id'] as String?,
webPort: _webPort,
),
);

Expand Down
4 changes: 4 additions & 0 deletions packages/fluttium_driver/lib/src/fluttium_driver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ class FluttiumDriver {
if (configuration.deviceId != null) ...['-d', configuration.deviceId!],
if (configuration.flavor != null) ...['--flavor', configuration.flavor!],
...configuration.dartDefines.expand((e) => ['--dart-define', e]),
if (configuration.webPort != null) ...[
'--web-port',
configuration.webPort!
],
];
_logger.detail('Running command: ${commandArgs.join(' ')}');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class DriverConfiguration extends Equatable {
this.flavor,
this.dartDefines = const [],
this.deviceId,
this.webPort,
});

/// {@macro driver_configuration}
Expand All @@ -26,6 +27,7 @@ class DriverConfiguration extends Equatable {
[])
.cast<String>(),
deviceId: json['deviceId']?.toString(),
webPort: json['webPort'] as String?,
);
}

Expand All @@ -45,8 +47,11 @@ class DriverConfiguration extends Equatable {
/// The device id to use for the driver.
final String? deviceId;

/// The port to use for the web application.
final String? webPort;

@override
List<Object?> get props => [target, flavor, dartDefines, deviceId];
List<Object?> get props => [target, flavor, dartDefines, deviceId, webPort];

/// Copy the configuration to a new instance with optional overrides.
DriverConfiguration copyWith({
Expand All @@ -55,12 +60,14 @@ class DriverConfiguration extends Equatable {
@Deprecated('Use `target` instead') String? mainEntry,
String? flavor,
List<String>? dartDefines,
String? webPort,
}) {
return DriverConfiguration(
deviceId: deviceId ?? this.deviceId,
target: target ?? mainEntry ?? this.target,
flavor: flavor ?? this.flavor,
dartDefines: dartDefines ?? this.dartDefines,
webPort: webPort ?? this.webPort,
);
}
}