feat(shorebird_cli): shorebird run support --flavor and --target (#416)
This commit is contained in:
@@ -19,11 +19,21 @@ class RunCommand extends ShorebirdCommand
|
||||
super.buildCodePushClient,
|
||||
super.validators,
|
||||
}) {
|
||||
argParser.addOption(
|
||||
'device-id',
|
||||
abbr: 'd',
|
||||
help: 'Target device id or name.',
|
||||
);
|
||||
argParser
|
||||
..addOption(
|
||||
'device-id',
|
||||
abbr: 'd',
|
||||
help: 'Target device id or name.',
|
||||
)
|
||||
..addOption(
|
||||
'target',
|
||||
abbr: 't',
|
||||
help: 'The main entrypoint file of the application.',
|
||||
)
|
||||
..addOption(
|
||||
'flavor',
|
||||
help: 'The product flavor to use when building the app.',
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -44,13 +54,17 @@ class RunCommand extends ShorebirdCommand
|
||||
logger.info('Running app...');
|
||||
|
||||
final deviceId = results['device-id'] as String?;
|
||||
final flavor = results['flavor'] as String?;
|
||||
final target = results['target'] as String?;
|
||||
final flutter = await process.start(
|
||||
'flutter',
|
||||
[
|
||||
'run',
|
||||
// Eventually we should support running in both debug and release mode.
|
||||
'--release',
|
||||
if (deviceId != null) ...['-d', deviceId],
|
||||
if (deviceId != null) '--device-id=$deviceId',
|
||||
if (flavor != null) '--flavor=$flavor',
|
||||
if (target != null) '--target=$target',
|
||||
...results.rest
|
||||
],
|
||||
runInShell: true,
|
||||
|
||||
@@ -157,14 +157,18 @@ void main() {
|
||||
verify(() => logger.info(output)).called(1);
|
||||
});
|
||||
|
||||
test('passes device-id when specified', () async {
|
||||
test('passes additional args when specified', () async {
|
||||
final tempDir = Directory.systemTemp.createTempSync();
|
||||
|
||||
final progress = _MockProgress();
|
||||
when(() => logger.progress(any())).thenReturn(progress);
|
||||
|
||||
const deviceId = 'test-device-id';
|
||||
const flavor = 'development';
|
||||
const target = './lib/main_development.dart';
|
||||
when(() => argResults['device-id']).thenReturn(deviceId);
|
||||
when(() => argResults['flavor']).thenReturn(flavor);
|
||||
when(() => argResults['target']).thenReturn(target);
|
||||
|
||||
when(() => process.stdout).thenAnswer((_) => const Stream.empty());
|
||||
when(() => process.stderr).thenAnswer((_) => const Stream.empty());
|
||||
@@ -186,7 +190,13 @@ void main() {
|
||||
).captured.first as List<String>;
|
||||
expect(
|
||||
args,
|
||||
equals(['run', '--release', '-d', deviceId]),
|
||||
equals([
|
||||
'run',
|
||||
'--release',
|
||||
'--device-id=$deviceId',
|
||||
'--flavor=$flavor',
|
||||
'--target=$target',
|
||||
]),
|
||||
);
|
||||
|
||||
await expectLater(result, equals(ExitCode.success.code));
|
||||
|
||||
Reference in New Issue
Block a user