-
Notifications
You must be signed in to change notification settings - Fork 57
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: honor forced framework for Remix and Hydrogen #5837
fix: honor forced framework for Remix and Hydrogen #5837
Conversation
// this indicate that framework's custom "detect" method doesn't honor the forced framework | ||
throw new Error(`Forced framework "${frameworkId}" was not detected.`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This just change error being thrown - previously it would throw
Invalid framework "remix". It should be one of: analog, angular, assemble, astro, blitz, brunch, cecil, create-react-app, docpad, docusaurus, eleventy, ember, expo, gatsby, gridsome, grunt, gulp, harp, hexo, hugo, hydrogen, jekyll, metalsmith, middleman, next, nuxt, observable, parcel, phenomic, quasar, qwik, react-static, redwoodjs, remix, roots, sapper, solid-js, solid-start, stencil, svelte, svelte-kit, vite, vue, vuepress, wintersmith, wmr, zola
which make no sense, so this just adds specific error message for what is actually happening
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this be displayed to users? If so, it might be nice to include what action they should be taking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should never be visible to user because I did add test in get-framework.test.ts
that checks if we ever hit that scenario - I'm testing it for all the frameworks we have, force the framework and the project looks like empty directory - this won't fully guarantee that it will never happen as only empty directory case is tested, but it should prevent most likely cases from being unnoticed and thus block the merge of changes that would lead to hitting this error case.
The difficulty with providing something actionable to user is that only custom code in each framework .detect()
method can cause problems
7e19e12
to
1706dca
Compare
20d1c85
to
8da6cc2
Compare
8da6cc2
to
2a59c12
Compare
🎉 Thanks for submitting a pull request! 🎉
Summary
Fixes https://linear.app/netlify/issue/FRB-1324/fix-failing-test-related-to-remix-framework-detection-in-cli
Because of the change in #5820 we now have scenarios where forcing framework via
netlify.toml#dev.framework
that is not honored by framework's detection, would print quite confusing error:It seems like we do have to ensure that if framework is forced - each framework detection need to honor it. Before Remix and Hydrogen adjustments that was actually the case (but we were not verifying it), because custom
detect()
method in frameworks was not really changing status of something being detected or not - it was just used to enrich default settings (often based on framework version etc).This adds a generic test testing if forced framework result in it being "detected" (or rather that forcing a framework is being honored) and add fallback cases to Remix and Hydrogen to use previous defaults if framework is forced and we fail to find any of possible configuration files (for classic compiler or vite variant)
It also implements this idea #5820 (comment) instead of current one, so we avoid doing multiple detection passes and use detection information about config file to decide if Vite or Classic Compiler option should be used)
For us to review and ship your PR efficiently, please perform the following steps:
we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or
something that`s on fire 🔥 (e.g. incident related), you can skip this step.
your code follows our style guide and passes our tests.
A picture of a cute animal (not mandatory, but encouraged)