fix(shorebird_cli): shorebird release android fails for existing release (#591)
This commit is contained in:
@@ -176,31 +176,39 @@ ${summary.join('\n')}
|
||||
}
|
||||
|
||||
var release = releases.firstWhereOrNull((r) => r.version == releaseVersion);
|
||||
if (release == null) {
|
||||
final flutterRevisionProgress = logger.progress(
|
||||
'Fetching Flutter revision',
|
||||
);
|
||||
final String shorebirdFlutterRevision;
|
||||
try {
|
||||
shorebirdFlutterRevision = await getShorebirdFlutterRevision();
|
||||
flutterRevisionProgress.complete();
|
||||
} catch (error) {
|
||||
flutterRevisionProgress.fail('$error');
|
||||
return ExitCode.software.code;
|
||||
}
|
||||
|
||||
final createReleaseProgress = logger.progress('Creating release');
|
||||
try {
|
||||
release = await codePushClient.createRelease(
|
||||
appId: app.id,
|
||||
version: releaseVersion,
|
||||
flutterRevision: shorebirdFlutterRevision,
|
||||
);
|
||||
createReleaseProgress.complete();
|
||||
} catch (error) {
|
||||
createReleaseProgress.fail('$error');
|
||||
return ExitCode.software.code;
|
||||
}
|
||||
if (release != null) {
|
||||
logger.err(
|
||||
'''
|
||||
It looks like you have an existing release for version ${lightCyan.wrap(releaseVersion)}.
|
||||
Please bump your version number and try again.''',
|
||||
);
|
||||
return ExitCode.software.code;
|
||||
}
|
||||
|
||||
final flutterRevisionProgress = logger.progress(
|
||||
'Fetching Flutter revision',
|
||||
);
|
||||
final String shorebirdFlutterRevision;
|
||||
try {
|
||||
shorebirdFlutterRevision = await getShorebirdFlutterRevision();
|
||||
flutterRevisionProgress.complete();
|
||||
} catch (error) {
|
||||
flutterRevisionProgress.fail('$error');
|
||||
return ExitCode.software.code;
|
||||
}
|
||||
|
||||
final createReleaseProgress = logger.progress('Creating release');
|
||||
try {
|
||||
release = await codePushClient.createRelease(
|
||||
appId: app.id,
|
||||
version: releaseVersion,
|
||||
flutterRevision: shorebirdFlutterRevision,
|
||||
);
|
||||
createReleaseProgress.complete();
|
||||
} catch (error) {
|
||||
createReleaseProgress.fail('$error');
|
||||
return ExitCode.software.code;
|
||||
}
|
||||
|
||||
// TODO(bryanoltman): Consolidate aab and other artifact creation.
|
||||
|
||||
+17
-19
@@ -245,7 +245,7 @@ flutter:
|
||||
).thenAnswer((_) async => [appMetadata]);
|
||||
when(
|
||||
() => codePushClient.getReleases(appId: any(named: 'appId')),
|
||||
).thenAnswer((_) async => [release]);
|
||||
).thenAnswer((_) async => []);
|
||||
when(
|
||||
() => codePushClient.createRelease(
|
||||
appId: any(named: 'appId'),
|
||||
@@ -433,9 +433,6 @@ Did you forget to run "shorebird init"?''',
|
||||
const error = 'oops';
|
||||
when(() => flutterRevisionProcessResult.exitCode).thenReturn(1);
|
||||
when(() => flutterRevisionProcessResult.stderr).thenReturn(error);
|
||||
when(
|
||||
() => codePushClient.getReleases(appId: any(named: 'appId')),
|
||||
).thenAnswer((_) async => []);
|
||||
final tempDir = setUpTempDir();
|
||||
setUpTempArtifacts(tempDir);
|
||||
final exitCode = await IOOverrides.runZoned(
|
||||
@@ -450,11 +447,24 @@ Did you forget to run "shorebird init"?''',
|
||||
).called(1);
|
||||
});
|
||||
|
||||
test('throws error when creating release fails.', () async {
|
||||
const error = 'something went wrong';
|
||||
test('throws error when existing releases exists.', () async {
|
||||
when(
|
||||
() => codePushClient.getReleases(appId: any(named: 'appId')),
|
||||
).thenAnswer((_) async => []);
|
||||
).thenAnswer((_) async => [release]);
|
||||
final tempDir = setUpTempDir();
|
||||
setUpTempArtifacts(tempDir);
|
||||
final exitCode = await IOOverrides.runZoned(
|
||||
command.run,
|
||||
getCurrentDirectory: () => tempDir,
|
||||
);
|
||||
verify(() => logger.err('''
|
||||
It looks like you have an existing release for version ${lightCyan.wrap(release.version)}.
|
||||
Please bump your version number and try again.''')).called(1);
|
||||
expect(exitCode, ExitCode.software.code);
|
||||
});
|
||||
|
||||
test('throws error when creating release fails.', () async {
|
||||
const error = 'something went wrong';
|
||||
when(
|
||||
() => codePushClient.createRelease(
|
||||
appId: any(named: 'appId'),
|
||||
@@ -476,9 +486,6 @@ Did you forget to run "shorebird init"?''',
|
||||
test('logs message when uploading release artifact that already exists.',
|
||||
() async {
|
||||
const error = 'something went wrong';
|
||||
when(
|
||||
() => codePushClient.getReleases(appId: any(named: 'appId')),
|
||||
).thenAnswer((_) async => []);
|
||||
when(
|
||||
() => codePushClient.createReleaseArtifact(
|
||||
artifactPath: any(named: 'artifactPath'),
|
||||
@@ -506,9 +513,6 @@ Did you forget to run "shorebird init"?''',
|
||||
|
||||
test('logs message when uploading aab that already exists.', () async {
|
||||
const error = 'something went wrong';
|
||||
when(
|
||||
() => codePushClient.getReleases(appId: any(named: 'appId')),
|
||||
).thenAnswer((_) async => []);
|
||||
when(
|
||||
() => codePushClient.createReleaseArtifact(
|
||||
artifactPath: any(named: 'artifactPath', that: endsWith('.aab')),
|
||||
@@ -535,9 +539,6 @@ Did you forget to run "shorebird init"?''',
|
||||
|
||||
test('throws error when uploading release artifact fails.', () async {
|
||||
const error = 'something went wrong';
|
||||
when(
|
||||
() => codePushClient.getReleases(appId: any(named: 'appId')),
|
||||
).thenAnswer((_) async => []);
|
||||
when(
|
||||
() => codePushClient.createReleaseArtifact(
|
||||
artifactPath: any(named: 'artifactPath'),
|
||||
@@ -562,9 +563,6 @@ Did you forget to run "shorebird init"?''',
|
||||
|
||||
test('throws error when uploading aab fails', () async {
|
||||
const error = 'something went wrong';
|
||||
when(
|
||||
() => codePushClient.getReleases(appId: any(named: 'appId')),
|
||||
).thenAnswer((_) async => []);
|
||||
when(
|
||||
() => codePushClient.createReleaseArtifact(
|
||||
artifactPath: any(named: 'artifactPath', that: endsWith('.aab')),
|
||||
|
||||
Reference in New Issue
Block a user