feat(shorebird_cli): shorebird release ios-framework-alpha supports --flavor and --target (#967)
This commit is contained in:
@@ -26,6 +26,15 @@ The version of the associated release (e.g. "1.0.0"). This should be the version
|
||||
of the iOS app that is using this module.''',
|
||||
mandatory: true,
|
||||
)
|
||||
..addOption(
|
||||
'target',
|
||||
abbr: 't',
|
||||
help: 'The main entrypoint file of the module.',
|
||||
)
|
||||
..addOption(
|
||||
'flavor',
|
||||
help: 'The product flavor to use when building the module.',
|
||||
)
|
||||
..addFlag(
|
||||
'force',
|
||||
abbr: 'f',
|
||||
@@ -61,9 +70,11 @@ of the iOS app that is using this module.''',
|
||||
showiOSStatusWarning();
|
||||
|
||||
const releasePlatform = ReleasePlatform.ios;
|
||||
final flavor = results['flavor'] as String?;
|
||||
final target = results['target'] as String?;
|
||||
final releaseVersion = results['release-version'] as String;
|
||||
final shorebirdYaml = ShorebirdEnvironment.getShorebirdYaml()!;
|
||||
final appId = shorebirdYaml.getAppId();
|
||||
final appId = shorebirdYaml.getAppId(flavor: flavor);
|
||||
final app = await codePushClientWrapper.getApp(appId: appId);
|
||||
|
||||
final existingRelease = await codePushClientWrapper.maybeGetRelease(
|
||||
@@ -80,7 +91,7 @@ of the iOS app that is using this module.''',
|
||||
final buildProgress = logger.progress('Building iOS framework');
|
||||
|
||||
try {
|
||||
await buildIosFramework();
|
||||
await buildIosFramework(flavor: flavor, target: target);
|
||||
} catch (error) {
|
||||
buildProgress.fail('Failed to build iOS framework: $error');
|
||||
return ExitCode.software.code;
|
||||
@@ -90,8 +101,7 @@ of the iOS app that is using this module.''',
|
||||
|
||||
final summary = [
|
||||
'''📱 App: ${lightCyan.wrap(app.displayName)} ${lightCyan.wrap('($appId)')}''',
|
||||
// TODO(felangel): uncomment once flavor support is added.
|
||||
// if (flavor != null) '🍧 Flavor: ${lightCyan.wrap(flavor)}',
|
||||
if (flavor != null) '🍧 Flavor: ${lightCyan.wrap(flavor)}',
|
||||
'📦 Release Version: ${lightCyan.wrap(releaseVersion)}',
|
||||
'''🕹️ Platform: ${lightCyan.wrap(releasePlatform.name)}''',
|
||||
];
|
||||
|
||||
@@ -209,13 +209,18 @@ mixin ShorebirdBuildMixin on ShorebirdCommand {
|
||||
}
|
||||
|
||||
/// Builds a release iOS framework (.xcframework) for the current project.
|
||||
Future<void> buildIosFramework() async {
|
||||
Future<void> buildIosFramework({
|
||||
String? flavor,
|
||||
String? target,
|
||||
}) async {
|
||||
const executable = 'flutter';
|
||||
final arguments = [
|
||||
'build',
|
||||
'ios-framework',
|
||||
'--no-debug',
|
||||
'--no-profile',
|
||||
if (flavor != null) '--flavor=$flavor',
|
||||
if (target != null) '--target=$target',
|
||||
...results.rest,
|
||||
];
|
||||
|
||||
|
||||
+70
@@ -447,5 +447,75 @@ flutter:
|
||||
).called(1);
|
||||
expect(exitCode, ExitCode.success.code);
|
||||
});
|
||||
|
||||
test(
|
||||
'succeeds when release is successful '
|
||||
'with flavors and target', () async {
|
||||
const flavor = 'development';
|
||||
final target = p.join('lib', 'main_development.dart');
|
||||
when(() => argResults['flavor']).thenReturn(flavor);
|
||||
when(() => argResults['target']).thenReturn(target);
|
||||
final tempDir = setUpTempDir();
|
||||
File(
|
||||
p.join(tempDir.path, 'shorebird.yaml'),
|
||||
).writeAsStringSync('''
|
||||
app_id: productionAppId
|
||||
flavors:
|
||||
development: $appId''');
|
||||
|
||||
final exitCode = await IOOverrides.runZoned(
|
||||
() => runWithOverrides(command.run),
|
||||
getCurrentDirectory: () => tempDir,
|
||||
);
|
||||
final arguments = [
|
||||
'build',
|
||||
'ios-framework',
|
||||
'--no-debug',
|
||||
'--no-profile',
|
||||
'--flavor=$flavor',
|
||||
'--target=$target',
|
||||
];
|
||||
verify(
|
||||
() => shorebirdProcess.run('flutter', arguments, runInShell: true),
|
||||
).called(1);
|
||||
verify(
|
||||
() => logger.info(
|
||||
any(that: contains('🍧 Flavor: ${lightCyan.wrap(flavor)}')),
|
||||
),
|
||||
).called(1);
|
||||
verify(() => logger.success('\n✅ Published Release!')).called(1);
|
||||
verify(
|
||||
() => logger.info(
|
||||
any(
|
||||
that: stringContainsInOrder(
|
||||
[
|
||||
'Your next step is to include the .xcframework files in',
|
||||
'/build/ios/framework/Release',
|
||||
'in your iOS app.'
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
).called(1);
|
||||
verify(
|
||||
() => codePushClientWrapper.createIosFrameworkReleaseArtifacts(
|
||||
appId: appId,
|
||||
releaseId: release.id,
|
||||
appFrameworkPath: any(
|
||||
named: 'appFrameworkPath',
|
||||
that: endsWith('build/ios/framework/Release/App.xcframework'),
|
||||
),
|
||||
),
|
||||
).called(1);
|
||||
verify(
|
||||
() => codePushClientWrapper.updateReleaseStatus(
|
||||
appId: appId,
|
||||
releaseId: release.id,
|
||||
platform: releasePlatform,
|
||||
status: ReleaseStatus.active,
|
||||
),
|
||||
).called(1);
|
||||
expect(exitCode, ExitCode.success.code);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user