#Astro Create Template followup CLI prompts

14 messages · Page 1 of 1 (latest)

spare dew
#

If I am making a Astro Template for use with npm create astro@latest -- --template <mytemplate> can I add my own interactive prompts/questions to the install script? How do I hook in?

right now I am doing a post install script asking my template users to run pnpm run template:init, but I'm not even sure my package.json will be preserved when installed via --template (haven't tested it yet, nor do I know if you need to get your template added to the template repo first)

rare drum
#

package.json for the template in question is always preserved, you can do test it with any of the templates on astro.build

spare dew
#

@rare drum thanks for that clarification. Can I hook into the questionaire and add my own questions and post-install scripts?

rare drum
#

that means overriding astro cli which I don't think is possible (at least I have never seen 1 on Internet)

#

but if you make your own cli app using clacks by nate helping users install and configure your template then I think its done and dusted

spare dew
#

yeah, so a 2 step process then

#

that is too bad we can't hook into houston create-astro

#

I'll drop it into #feedback-ideas

#

@rare drum thanks for responding!

spare dew
#

I guess theoretically I could also make a create-mytemplate and invoke create-astro first, then do my followup stuff?

#

which would at least make the user experience npm create my-astro-template@latest

#

but if there is additional options the user wants to bubble up to create-astro I would have to handle that and keep step with it.

rare drum
#

this is something i can't answer out of sheer inexperience 😔, can't imagine what will you cook houston_happy