Right now if an auth generator is run multiple times it will add more and more lines of config to web/src/index.js which isn't the greatest experience.
match() says that the line that's going to be inserted is already there, but keep going to the next step.~ Yep, the first thing we should check (before the first step of adding packages) is if <AuthProvider> already exists and if so, error out with a message.<AuthProvider> already exists and if the type doesn't match the generator that's about to run, exit/error and leave a note that the other auth type has already been added.~ This will be covered by the first solution.Opinions (and PRs) welcome!
🔥💣💥🤯
maybe?
What would be the use case for running it more than once on purpose? It seems reasonable to me to just bail completely if <AuthProvider> is already set.
We can display a warning saying that the AuthProvider already exists, or use --force flag with the generator that resets the existing AuthProvider
Here's an example of how Ruby on Rails handles this scenario
This is the warning I get when I try to create a User model that already exists
The name 'User' is either already used in your application or reserved by Ruby on Rails. Please choose an alternative or use --force to skip this check and run this generator again.
Running the generator again with --force will reset the existing model, i.e. It removes the code that we had earlier
@thedavidprice @peterp I'd be interested in tackling this one. Do we want to implement a --force flag that lets the user overwrite their previous AuthProvider? I think that sounds pretty useful!
@amorriscode see @mojombo's previous comment
Most helpful comment
What would be the use case for running it more than once on purpose? It seems reasonable to me to just bail completely if
<AuthProvider>is already set.