Skip to content

Conversation

@stuartmorgan-g
Copy link
Contributor

Description

Adds initial support for flutter create of apps and plugins. This is derived from the current FDE example app and sample plugin, adding template values where relevant.

Since the APIs/tooling/template aren't stable yet, the app template includes a version marker, which will be updated each time there's a breaking change. The build now checks that the template version matches the version known by that version of the tool, and gives a specific error message when there's a mismatch, which improves over the current breaking change experience of hitting whatever build failure the breaking change causes and having to figure out that the problem is that the runner is out of date. It also adds a warning to the create output about the fact that it won't be stable.

Plugins don't currently have a version marker since in practice this is not a significant problem for plugins yet the way it is for runners; we can add it later if that changes.

Related Issues

#30704

Tests

I added the following tests:

  • Checks that the app and plugin templates include windows when requested, and don't when not requested.
  • Error message tests for mismatches of template version.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.
  • Yes, this is a breaking change.

@fluttergithubbot fluttergithubbot added the tool Affects the "flutter" command-line tool. See also t: labels. label Mar 3, 2020
@stuartmorgan-g
Copy link
Contributor Author

I still need to do the manual tests on this one, but it should be good to review as-is.


# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
Copy link
Contributor

Choose a reason for hiding this comment

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

blast from the past

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am torn on whether we should use this giant stock ignore file, or instead do just what we actually need (which is probably not much, but I may get wrong initially and have to adjust). Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

For the most part, we've followed the later policy. This works great until we need to add something, and users end up without. For a pre-stable template I think it won't matter as much. It is harder to explain "why is X here" when pointing at the catch-all

Copy link
Contributor

Choose a reason for hiding this comment

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

Though, maybe someone writes an app and just happens to call a folder bower_components 🤷‍♂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll redo this when I'm at my Windows machine, doing just what shows up for me in an edit+build cycle.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I slimmed it way down. I left a few of the very basic user-file patterns in case they are triggered by things I just didn't do.

I suspect we'll find a few things over time that I should have left in but didn't, but we can always re-add things as we find them.

@jonahwilliams
Copy link
Contributor

The non UTF files need an exception added in dev/bots/test.dart . This is mostly to prevent us from accidentally adding large binaries or images, should be okay for templates

@stuartmorgan-g
Copy link
Contributor Author

The non UTF files need an exception added in dev/bots/test.dart .

Added an exception for the .ico. It looks like the rc file can be UTF-8 in VS 2019, so I've pushed a version with that. I need to double-check when I'm at my Windows machine though since it sounds like the exact behavior changed during the development of VS 2019 so I'm not 100% sure it will preserve UTF-8 on edit+save, and if it doesn't I'll switch it back to UTF-16.

@stuartmorgan-g
Copy link
Contributor Author

I'm not 100% sure it will preserve UTF-8 on edit+save

Tested adding a resource via VS 2019 and it still saved out in UTF-8, so it looks like that's fine to change!

@stuartmorgan-g
Copy link
Contributor Author

Added an exception for the .ico.

Turns out I was looking at the wrong check.

@Hixie, the code I would actually need to change to allow adding the icon for this new template has multiple comments saying not to change it, but don't point to any suggestions about what to do instead and only say to talk to you.

  1. What is the right way to have an icon in a new template now?
  2. Can we have a more scalable solution in the documentation than "talk to one specific person who might not be in the office when you encounter this problem"?

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

@stuartmorgan-g
Copy link
Contributor Author

@jonahwilliams PTAL; this now includes the new code to use flutter_template_images. Requires flutter/packages#118 to land and be published before it'll work, but it can be reviewed in parallel.

Unit test coverage of template.dart is currently poor, but I did add a new unit test for the new functionality. I also de-global.fs'd it in support of that test.

@stuartmorgan-g
Copy link
Contributor Author

flutter_template_images has been published; this now works end to end.

@Hixie
Copy link
Contributor

Hixie commented Mar 17, 2020

Can you do me a favour and add a comment to the place that verifies that there's no binaries saying that if anyone wants to add or change images in the templates, they should do it via your package and pointing to the logic for how to do it?

Thanks for setting this logic up, this is great. I'm glad we have a real solution for avoiding images in the templates now.

@stuartmorgan-g
Copy link
Contributor Author

Can you do me a favour and add a comment to the place that verifies that there's no binaries saying that if anyone wants to add or change images in the templates, they should do it via your package and pointing to the logic for how to do it?

Done. I meant to do that once I had something working, thanks for the reminder.

@stuartmorgan-g
Copy link
Contributor Author

For reasons I don't understand adding a new dependency made me run update-packages --force-upgrade, which made a ton of changes, but none of them related to the package that I added. Is that normal?

@stuartmorgan-g stuartmorgan-g force-pushed the windows-create-pre-stable branch from 75120eb to e0ea3a9 Compare March 18, 2020 02:09
// Returns the directory containing the 'name' template directory in
// flutter_template_images, to resolve image placeholder against.
Directory templateImageDirectory(String name, FileSystem fileSystem) {
final String packageFilePath = fileSystem.path.join(
Copy link
Contributor

Choose a reason for hiding this comment

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

There might be cases where this .packages file doesn't exist. I think the zip uploaded SDKs do not include the packages since they would contains paths of the zipping machine they would be incorrect for clients.

Less commonly, the other way this could go wrong is that the user could update or delete their pub cache. Since the tool is snapshotted, it is still able to start even if the .packages is pointing to junk.

First you need to check for the existence of the .packages and the imagePackageLibDir. If either is missing you'll need to run a pub get in the flutter_tools directory. It might be easier to hoist this work out of template creation into a separate service class and drill that down instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks for flagging that as I'd never have hit it in my testing.

I haven't done a full sweep of tests locally so I may need to adjust the environment in some other tests the way I've done in project_tests.

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

This should handle missing .packages/cache as noted in my comment above, otherwise looks good!

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

stuartmorgan-g added a commit to stuartmorgan-g/flutter-desktop-embedding that referenced this pull request Mar 19, 2020
Recreates testbed/windows/ from the new template added in
flutter/flutter#51895

Diffs that don't ignore whitespace show most files have changed
completely due to differences in how the two repos handle line endings
on checkout; actual diffs are very small.
stuartmorgan-g added a commit to google/flutter-desktop-embedding that referenced this pull request Mar 23, 2020
Recreates testbed/windows/ from the new template added in
flutter/flutter#51895

Diffs that don't ignore whitespace show most files have changed
completely due to differences in how the two repos handle line endings
on checkout; actual diffs are very small.
@stuartmorgan-g stuartmorgan-g merged commit 685e9d1 into flutter:master Mar 23, 2020
@stuartmorgan-g stuartmorgan-g deleted the windows-create-pre-stable branch March 23, 2020 17:42
@Hixie
Copy link
Contributor

Hixie commented Mar 23, 2020

For reasons I don't understand adding a new dependency made me run update-packages --force-upgrade, which made a ton of changes, but none of them related to the package that I added. Is that normal?

This is normal. When you add a dependency, we have to recalculate the full dependency chart so that we can make sure all the packages in the repo use the same versions of each package.

@Hixie
Copy link
Contributor

Hixie commented Mar 23, 2020

(ideally we'd have a bot that does this daily so it would never be a lot of changes at once)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants