feat: add support for custom update tracks (#3118)
This commit is contained in:
@@ -93,7 +93,6 @@ To target the latest release (e.g. the release that was most recently updated) u
|
||||
)
|
||||
..addOption(
|
||||
'track',
|
||||
allowed: DeploymentTrack.values.map((v) => v.channel),
|
||||
help: 'The track to publish the patch to.',
|
||||
defaultsTo: DeploymentTrack.stable.channel,
|
||||
)
|
||||
@@ -198,10 +197,7 @@ NOTE: this is ${styleBold.wrap('not')} recommended. Asset changes cannot be incl
|
||||
bool get useLatestRelease => results['release-version'] == 'latest';
|
||||
|
||||
/// The deployment track to publish the patch to.
|
||||
DeploymentTrack get track {
|
||||
final channel = results['track'] as String;
|
||||
return DeploymentTrack.values.firstWhere((t) => t.channel == channel);
|
||||
}
|
||||
DeploymentTrack get track => DeploymentTrack(results['track'] as String);
|
||||
|
||||
@override
|
||||
Future<int> run() async {
|
||||
@@ -557,6 +553,7 @@ Please re-run the release command for this version or create a new release.''');
|
||||
DeploymentTrack.staging => '🟠 Track: ${lightCyan.wrap('Staging')}',
|
||||
DeploymentTrack.beta => '🔵 Track: ${lightCyan.wrap('Beta')}',
|
||||
DeploymentTrack.stable => '🟢 Track: ${lightCyan.wrap('Stable')}',
|
||||
final String trackName => '⚪️ Track: ${lightCyan.wrap(trackName)}',
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
@@ -95,7 +95,6 @@ This is only applicable when previewing Android releases.''',
|
||||
)
|
||||
..addOption(
|
||||
'track',
|
||||
allowed: DeploymentTrack.values.map((v) => v.channel),
|
||||
help: 'The track to preview.',
|
||||
defaultsTo: DeploymentTrack.stable.channel,
|
||||
);
|
||||
@@ -119,10 +118,7 @@ This is only applicable when previewing Android releases.''',
|
||||
String get description => 'Preview a specific release on a device.';
|
||||
|
||||
/// The deployment track to publish the patch to.
|
||||
DeploymentTrack get track {
|
||||
final channel = results['track'] as String;
|
||||
return DeploymentTrack.values.firstWhere((t) => t.channel == channel);
|
||||
}
|
||||
DeploymentTrack get track => DeploymentTrack(results['track'] as String);
|
||||
|
||||
@override
|
||||
Future<int> run() async {
|
||||
@@ -382,10 +378,10 @@ This is only applicable when previewing Android releases.''',
|
||||
}
|
||||
}
|
||||
|
||||
final progress = logger.progress('Using ${track.name} track');
|
||||
final progress = logger.progress('Using $track track');
|
||||
try {
|
||||
await setChannelOnLinuxApp(
|
||||
channel: track.name,
|
||||
channel: track.channel,
|
||||
bundleDirectory: appDirectory,
|
||||
);
|
||||
progress.complete();
|
||||
@@ -460,7 +456,7 @@ This is only applicable when previewing Android releases.''',
|
||||
|
||||
await setChannelOnWindowsApp(
|
||||
appDirectory: appDirectory,
|
||||
channel: track.name,
|
||||
channel: track.channel,
|
||||
);
|
||||
|
||||
final exeFile = appDirectory.listSync().whereType<File>().firstWhere(
|
||||
@@ -527,7 +523,10 @@ This is only applicable when previewing Android releases.''',
|
||||
}
|
||||
}
|
||||
|
||||
await setChannelOnMacosApp(appDirectory: appDirectory, channel: track.name);
|
||||
await setChannelOnMacosApp(
|
||||
appDirectory: appDirectory,
|
||||
channel: track.channel,
|
||||
);
|
||||
|
||||
final logs = await open.newApplication(path: appDirectory.path);
|
||||
final completer = Completer<void>();
|
||||
@@ -656,7 +655,7 @@ This is only applicable when previewing Android releases.''',
|
||||
);
|
||||
|
||||
if (File(apksPath).existsSync()) File(apksPath).deleteSync();
|
||||
final progress = logger.progress('Using ${track.name} track');
|
||||
final progress = logger.progress('Using $track track');
|
||||
try {
|
||||
await setChannelOnAab(aabFile: aabFile, channel: track.channel);
|
||||
progress.complete();
|
||||
@@ -779,7 +778,7 @@ This is only applicable when previewing Android releases.''',
|
||||
}
|
||||
}
|
||||
|
||||
final progress = logger.progress('Using ${track.name} track');
|
||||
final progress = logger.progress('Using $track track');
|
||||
try {
|
||||
await setChannelOnRunner(
|
||||
runnerDirectory: runnerDirectory,
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
/// The deployment track to use when deploying to Shorebird's servers
|
||||
enum DeploymentTrack {
|
||||
extension type const DeploymentTrack(String value) {
|
||||
/// An internal track for validating changes.
|
||||
staging('staging'),
|
||||
static const staging = DeploymentTrack('staging');
|
||||
|
||||
/// A public track for publishing changes to a limited audience.
|
||||
beta('beta'),
|
||||
static const beta = DeploymentTrack('beta');
|
||||
|
||||
/// A public track for publishing changes to production.
|
||||
stable('stable');
|
||||
|
||||
const DeploymentTrack(this.channel);
|
||||
static const stable = DeploymentTrack('stable');
|
||||
|
||||
/// The name of the channel associated with the track.
|
||||
final String channel;
|
||||
String get channel => value;
|
||||
}
|
||||
|
||||
@@ -559,6 +559,35 @@ void main() {
|
||||
});
|
||||
|
||||
group('confirmCreatePatch', () {
|
||||
group('when using a custom deployment track', () {
|
||||
setUp(() {
|
||||
when(() => argResults['track']).thenReturn('custom-track');
|
||||
});
|
||||
|
||||
test('logs correct summary', () async {
|
||||
final expectedSummary = [
|
||||
'''📱 App: ${lightCyan.wrap(appDisplayName)} ${lightCyan.wrap('($appId)')}''',
|
||||
'📦 Release Version: ${lightCyan.wrap(releaseVersion)}',
|
||||
'''🕹️ Platform: ${lightCyan.wrap(patcher.releaseType.releasePlatform.displayName)} ${lightCyan.wrap('[arm32 (42 B)]')}''',
|
||||
'⚪️ Track: ${lightCyan.wrap('custom-track')}',
|
||||
];
|
||||
await expectLater(
|
||||
runWithOverrides(
|
||||
() => command.confirmCreatePatch(
|
||||
app: appMetadata,
|
||||
releaseVersion: releaseVersion,
|
||||
patcher: patcher,
|
||||
patchArtifactBundles: patchArtifactBundles,
|
||||
),
|
||||
),
|
||||
completes,
|
||||
);
|
||||
verify(
|
||||
() => logger.info(any(that: contains(expectedSummary.join('\n')))),
|
||||
).called(1);
|
||||
});
|
||||
});
|
||||
|
||||
group('when has flavors', () {
|
||||
const flavor = 'development';
|
||||
setUp(() {
|
||||
|
||||
Reference in New Issue
Block a user