Skip to content

fix: throw exception if flavor not found in shorebird.yaml #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/flutter_tools/gradle/src/main/groovy/flutter.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,11 @@ class FlutterPlugin implements Plugin<Project> {

// Update the app_id to the correct flavor if one was provided.
if (variant.flavorName != null && !variant.flavorName.isEmpty()) {
shorebirdYamlData['app_id'] = shorebirdYamlData.flavors[variant.flavorName]
def shorebirdFlavor = shorebirdYamlData.flavors[variant.flavorName]
if (shorebirdFlavor == null) {
throw new GradleException("Flavor '${variant.flavorName}' not found in shorebird.yaml")
}
shorebirdYamlData['app_id'] = shorebirdFlavor
}

// Remove any flavors. This is a no-op if the flavors key doesn't exist.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,16 @@ base_url: https://example.com
final Directory tempDir = Directory.systemTemp.createTempSync('shorebird_yaml_test.');
final File tempFile = File('${tempDir.path}/shorebird.yaml');
tempFile.writeAsStringSync(yamlContents);
updateShorebirdYaml(const BuildInfo(BuildMode.release, 'foo', treeShakeIcons: false), tempFile.path, environment: <String, String>{'SHOREBIRD_PUBLIC_KEY': '4-a'});
updateShorebirdYaml(
const BuildInfo(
BuildMode.release,
'foo',
treeShakeIcons: false,
packageConfigPath: '',
),
tempFile.path,
environment: <String, String>{'SHOREBIRD_PUBLIC_KEY': '4-a'},
);
final String updatedContents = tempFile.readAsStringSync();
// Order is not guaranteed, so parse as YAML to compare.
final YamlDocument updated = loadYamlDocument(updatedContents);
Expand Down
Loading