Skip to content
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

fix: shorebird preview to identify shorebird projects with flavors #1854

Merged
merged 6 commits into from
Apr 3, 2024

Conversation

erickzanardo
Copy link
Contributor

@erickzanardo erickzanardo commented Apr 3, 2024

Description

Uses the flavor values at shorebird.yaml to prompt for which flavor to use when using shorebird preview

Fixes #1836

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

Co-authored-by: Bryan Oltman <bryan@shorebird.dev>
Co-authored-by: Bryan Oltman <bryan@shorebird.dev>
Copy link

codecov bot commented Apr 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (ce39c85) to head (805b968).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1854   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          173       173           
  Lines         5486      5489    +3     
=========================================
+ Hits          5486      5489    +3     
Flag Coverage Δ
shorebird_cli 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 183 to 190
Future<String?> promptForFlavor(
List<String> flavors,
) async {
return logger.chooseOne<String>(
'Which app flavor?',
choices: flavors,
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we gain much by wrapping this in its own function, as the call to logger.chooseOne is not substantially more complex than the call to promptForFlavor.

packages/shorebird_cli/pubspec.lock Outdated Show resolved Hide resolved
Comment on lines 735 to 737
() => logger.chooseOne<String>(
any(),
choices: any(named: 'choices'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably verify that the flavors were provided as arguments to chooseOne

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enought! I've changed it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you push? I'm still seeing:

 verify(
          () => logger.chooseOne<String>(
            any(),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-04-03 at 13 52 16

I pushed yes! That is weird, I am seeing it correctly as shown in the print above

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! The issue is just that the test only has a single flavor. We should probably update that (and maybe change the command to not prompt if only one flavor is present, although that seems like sort of a silly setup)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, yeah, fair point!

Should we do that handling in a different PR though? I feel that this PR is addressing the detecting a shorebird project that has flavors, no matter the number, then auto selecting the only flavor would probably be a change of its own?

Let me know if you agree, otherwise I am happy to update this PR to include this as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the "single flavor" fix can be done in a future PR (if ever), but the test should probably be updated to include more than one flavor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, I've updated it

Copy link
Contributor

@bryanoltman bryanoltman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple small comments, but otherwise looks good! I'd suggest adding a note in the PR description explaining how you fixed the issue (something like "detects flavors in shorebird.yaml and prompts user to pick channel instead of app").

@bryanoltman
Copy link
Contributor

Looks great, ship it!

@erickzanardo erickzanardo merged commit 87f5d43 into main Apr 3, 2024
8 checks passed
@erickzanardo erickzanardo deleted the fix/shorebird-preview-flavors branch April 3, 2024 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix: shorebird preview doesn't think I'm inside a project
3 participants