-
-
Notifications
You must be signed in to change notification settings - Fork 429
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
feat: use default prompts values on non-interactive mode #630
base: master
Are you sure you want to change the base?
Conversation
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.
Looks this will be solved in saojs v2 by using mock: true
.
https://saojs.org/#testing-prompts
@egoist Is that possible to make use default prompts value and answers object
a formal option rather than mock for testing purpose ?
@patzick BTW, you can import |
Hey, @clarkdo thanks for jumping in! Solution with importing const myAnswers // combination of provided answers and defaults from create-nuxt-app/lib/prompts
const createNuxtApp = require('create-nuxt-app')
await createNuxtApp(myAnswers) this would ensure we're always using the same version, but it cannot be done this way. If you have any other suggestions for solving that problem, I'd love to listen, but for now, only this PR is solving this problem and allowing to create new nuxt project via npx passing always the same answers as param. |
Hi @patzick , I think you can specify npx -p create-nuxt-app and the script you pasted, then you’ll always use latest create-nuxt-app. |
I ll review this shortly and also ask other team members review, if team agrees with this fix, I think we can merge it for now as a quick fix and remove when saojs released better solution. |
@nuxt/framework Can you please review and take a look at above comments ? |
I like the idea but instead I would create another flag named npx create-nuxt-app my-app --defaults |
Shall we close it since we have no response from the author? |
hey @atinux flag |
Hey!
We have a CLI process, which uses
create-nuxt-app
in non-interactive mode to prepare a new empty project. Unfortunately, providing--answers
causes that all default values from prompts are omitted, so it's kinda "all or nothing", so adding any value to prompts is a breaking change for CI process.In this PR I jumped into a case, when
--answers
flag is provided. Then I extract all default answers fromprompts
and overwrite them only by values provided inanswers
flag.So users are able now to invoke non-interactive mode just by passing an empty object and project with default values will be created.
One thing I wasn't sure how to approach was interpolated default values. I added
cliDefault
property inside the prompt object, to provide a static default value as, at this point, I had no access to these values.Hope you'll like that :) cheers!