Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanoltman committed Jan 29, 2025
1 parent 64be691 commit 5634e39
Show file tree
Hide file tree
Showing 4 changed files with 467 additions and 28 deletions.
85 changes: 60 additions & 25 deletions packages/shorebird_cli/lib/src/commands/release/linux_releaser.dart
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import 'dart:io';

import 'package:mason_logger/mason_logger.dart';
import 'package:path/path.dart' as p;
import 'package:platform/platform.dart';
import 'package:shorebird_cli/src/artifact_builder.dart';
import 'package:shorebird_cli/src/artifact_manager.dart';
import 'package:shorebird_cli/src/code_push_client_wrapper.dart';
import 'package:shorebird_cli/src/commands/commands.dart';
import 'package:shorebird_cli/src/commands/release/releaser.dart';
import 'package:shorebird_cli/src/doctor.dart';
import 'package:shorebird_cli/src/extensions/arg_results.dart';
import 'package:shorebird_cli/src/logging/logging.dart';
import 'package:shorebird_cli/src/platform/platform.dart';
import 'package:shorebird_cli/src/release_type.dart';
import 'package:shorebird_cli/src/shorebird_documentation.dart';
import 'package:shorebird_cli/src/shorebird_flutter.dart';
import 'package:shorebird_cli/src/third_party/flutter_tools/lib/src/base/process.dart';
import 'package:shorebird_cli/src/shorebird_validator.dart';
import 'package:shorebird_cli/src/third_party/flutter_tools/lib/flutter_tools.dart';
import 'package:shorebird_code_push_client/shorebird_code_push_client.dart';

/// {@template linux_releaser}
Expand All @@ -24,10 +29,44 @@ class LinuxReleaser extends Releaser {
});

@override
Future<void> assertArgsAreValid() async {}
Future<void> assertArgsAreValid() async {
if (argResults.wasParsed('release-version')) {
logger.err(
'''
The "--release-version" flag is only supported for aar and ios-framework releases.
To change the version of this release, change your app's version in your pubspec.yaml.''',
);
throw ProcessExit(ExitCode.usage.code);
}
}

@override
Future<void> assertPreconditions() async {}
Future<void> assertPreconditions() async {
try {
await shorebirdValidator.validatePreconditions(
checkUserIsAuthenticated: true,
checkShorebirdInitialized: true,
validators: doctor.linuxCommandValidators,
supportedOperatingSystems: {Platform.linux},
);
} on PreconditionFailedException catch (e) {
throw ProcessExit(e.exitCode.code);
}
final flutterVersionArg = argResults['flutter-version'] as String?;
if (flutterVersionArg != null) {
final version =
await shorebirdFlutter.resolveFlutterVersion(flutterVersionArg);
if (version != null && version < minimumSupportedLinuxFlutterVersion) {
logger.err(
'''
Linux releases are not supported with Flutter versions older than $minimumSupportedLinuxFlutterVersion.
For more information see: ${supportedFlutterVersionsUrl.toLink()}''',
);
throw ProcessExit(ExitCode.usage.code);
}
}
}

@override
Future<FileSystemEntity> buildReleaseArtifacts() async {
Expand All @@ -36,30 +75,24 @@ class LinuxReleaser extends Releaser {
'Building Linux application with Flutter $flutterVersionString',
);

final base64PublicKey = argResults.encodedPublicKey;
try {
await artifactBuilder.buildLinuxApp();
await artifactBuilder.buildLinuxApp(
base64PublicKey: base64PublicKey,
);
} on Exception catch (e) {
logger.err('Failed to build Linux application: $e');
buildAppBundleProgress.fail('$e');
throw ProcessExit(ExitCode.software.code);
}

buildAppBundleProgress.complete(
'Built Linux application with Flutter $flutterVersionString',
);

return _bundleDirectory;
return artifactManager.linuxReleaseDirectory;
}

Directory get _bundleDirectory => Directory(
p.join(
'build',
'linux',
'x64',
'release',
'bundle',
),
);

@override
Future<String> getReleaseVersion({
required FileSystemEntity releaseArtifactRoot,
Expand All @@ -69,7 +102,10 @@ class LinuxReleaser extends Releaser {
);

@override
String get postReleaseInstructions => 'TODO: post release instructions here';
String get postReleaseInstructions => '''
Linux release created at ${artifactManager.linuxReleaseDirectory.path}.
''';

@override
ReleaseType get releaseType => ReleaseType.linux;
Expand All @@ -78,11 +114,10 @@ class LinuxReleaser extends Releaser {
Future<void> uploadReleaseArtifacts({
required Release release,
required String appId,
}) async {
await codePushClientWrapper.createLinuxReleaseArtifacts(
appId: appId,
releaseId: release.id,
bundlePath: _bundleDirectory.path,
);
}
}) =>
codePushClientWrapper.createLinuxReleaseArtifacts(
appId: appId,
releaseId: release.id,
bundlePath: artifactManager.linuxReleaseDirectory.path,
);
}
5 changes: 5 additions & 0 deletions packages/shorebird_cli/lib/src/doctor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class Doctor {
/// Validators that verify shorebird will work on iOS.
final List<Validator> iosCommandValidators = [];

/// Validators that verify shorebird will work on Windows.
final List<Validator> linuxCommandValidators = [
// Check whether powershell is installed?
];

/// Validators that verify shorebird will work on macOS.
final List<Validator> macosCommandValidators = [
MacosEntitlementsValidator(),
Expand Down
Loading

0 comments on commit 5634e39

Please sign in to comment.