Lets say i have an react typescript template. Now there are 2 slightly different versions of the template. It would be cool if there is an approach to configure the template with the console. An example is the setup of a vite project(You can configure framework and language)
Can i create the templates based on the user input(i dont know if it should be triggered by git clone or npm install
Vite example: Prompt
Solution i came across: Using
inquirer packageyou can prompt the user for the input in my case it looks like this: Inquirer promptI can run the inquirer script as a postinstall script(runs directly after npm install). Here is the configuration for the prompt:
Based on the users response, I can configure which files I want to include in my template.
Edit: The approach is quite simple: after receiving input from the user, you can modify the necessary files using another script. Once the template has been generated, you can then run an eject script that deletes all of the files (including itself) that were used in the process.