-
Notifications
You must be signed in to change notification settings - Fork 342
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
Dev framework matching and functions:invoke bug fixes #857
Conversation
… into consideration values in detectorsFiles ending in '.js' while devConfig.framework value shouldn't.
…plit config.dev and flags into two separate parameters when passing into serverSettings() instead of merging them.
@@ -41,7 +41,8 @@ class FunctionsInvokeCommand extends Command { | |||
process.exit(1) | |||
} | |||
|
|||
let settings = await serverSettings(Object.assign({}, config.dev, flags)) | |||
// Pass in console.log as the logger for now. | |||
let settings = await serverSettings(config.dev, flags, console.log) |
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.
I could be wrong on this; but it didn't appear that config.dev
and flags
should be getting merged here and passed as the devConfig
argument to serverSettings
when it takes in flags
as the second argument. Also, we'll get an NPE with nothing passed for the third argument (log
).
Also, it appears there will be some conflicts with #843.
|
||
// detectorsFiles end in '.js`; but devConfig.framework shouldn't. To test for match, append '.js' to devConfig.framework. | ||
const detectorName = detectorsFiles.find(dt => dt === `${devConfig.framework}.js`) | ||
if (!detectorName) throw new Error(`Unsupported value '${devConfig.framework}' provided for "framework" option in config`) |
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 appears .js
was being appended to the wrong value here. Also, I added the actual unsupported value to the error so it's a more helpful error (hopefully).
const detector = loadDetector(detectorName) | ||
const detectorResult = detector() | ||
if (!detectorResult) throw new Error(`Specified "framework" detector "${devConfig.framework}" did not pass requirements for your project`) | ||
|
||
settings.args = chooseDefaultArgs(detectorResult.possibleArgsArrs) | ||
// Merge detectorResult default settings into settings Object. | ||
Object.assign(settings, detectorResult) |
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.
Not sure if this is right; but it didn't appear we were really using the detectorResult
fully (chooseDefaultArgs()
looks like it doesn't pull in all the defaults that we want).
I'm not sure why the checks are failing, because Edit: I just pushed after merging in the latest from |
Confirm that I've seen most of these things pop up tonight after updating as well. Ended up rolling back to 2.46.0 because even when spoofing the framework |
Is this still relevant? Looks like both of the issues in this PR are resolved by #843 |
Yes, we can close this. Thanks for the hints @MuffinTheMan |
- Summary
Fixes #847
I believe this might also fix #441
When running
netlify dev
withframework = "svelte"
in the[dev]
section ofnetlify.toml
, I got the error:Unsupported value provided for "framework" option in config
.It turns out the logic would've required me to use
framework = "svelte.js.js"
, because.js
was being appended to the file name we wanted to check"svelte"
against instead of appending.js
to `"svelte" to check against the file name. This has been fixed.I also noticed that the
svelte.js
settings weren't actually being used (I noticed because I couldn't runnetlify dev
, since I wasn't providing atargetPort
, which should've been pulled fromproxyPort
insvelte.js
). I ended up merging the defaults fromsvelte.js
(or the corresponding detector for whichever framework is being used) intosettings
to make use of these defaults.Finally, I noticed that parameters were not being passed properly into the
serverSettings
function fromFunctionsInvokeCommand.run()
, which was resulting in NPEs in my situation when callingserverSettings
(when runningnetlify functions:invoke
). The proper parameters (hopefully) are now being passed, andconsole.log
is being sent through as thelog
function (seemed like the simplest solution at this time).- Test plan
Run
netlify dev
with some optionframework = "svelte"
(or some other valid framework) and verify the dev server is run and can be reached properly.In my case,
netlify.toml
:Verify you can invoke a function via
netlify function:invoke
with some test function like:Note: this isn't working for me (but it makes it further than it did before the fixes in this PR, since it at least doesn't die from an NPE); there appears to be some other bug that I would appreciate feedback on so I can perhaps track it down. I can run the function properly by directly hitting the localhost url when running
netlify dev
. Here's what I get:- Description for the changelog
netlify dev framework config and function:invoke bug fixes
- A picture of a cute animal (not mandatory but encouraged)