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: Add fallback for multiple frameworks #22

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Shane-Donlon
Copy link

@Shane-Donlon Shane-Donlon commented Feb 2, 2025

☕️ Reasoning

🧢 Checklist

  • Documentation
  • Tests
  • Ready to be merged

🎫 Affected issues

Fixes #20

Hi team,
Came across this issue yesterday and had a few minutes today.

In short if multiple frameworks are detected the below will be the terminal output.
(Confirmed copy to clipboard as working)

auth secret
Multiple supported frameworks detected.
Secret generated. It has been copied to your clipboard, paste it to your .env/.env.local file to continue.

if copy to clipboard fails
the auth secret will still be added to the terminal for the Developer to add to their own file / files.

I also added a little bit of error handling to detect.js

 console.error("An error occurred while detecting the framework.")
    console.error(error)
    process.exit(0)

The thinking here was that since the origin return is "unknown" this would cause 2 error messages as highlighted below
error one in line 38

https://github.com/nextauthjs/cli/blob/main/lib/detect.js#L38

error 2 in line 46

No framework detected. Currently supported frameworks are: next, sveltekit, expres

https://github.com/nextauthjs/cli/blob/main/lib/detect.js#L46

Which is a potential cause of confusion (as highlighted in Issue 20)

I opted to just end the process after the error.

Feedback welcome.
Have a great day.

📌 Resources

@Shane-Donlon
Copy link
Author

Oh I did forget to update the package.json version in this PR, but I have 2 PRs opened, so could be (potentially) merged as a single release?

@Shane-Donlon
Copy link
Author

Upon self-review I have noticed that the error would duplicate the message value in the terminal

'value' is already called as part of 'multipleFrameworks'

More than happy to change this before merging, but I'll wait for a review first to see if the approach is the correct approach.

catch (error) { console.log( "An error occurred while copying the secret to your clipboard." ) console.log(message.multipleFrameworks) console.log(message.value)

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.

npx auth secret: No Framework detected error
1 participant