Issues while creating custom CLI preset


I am creating a custom CLI preset to ease creation of projects. I have a pretty clear vision of what kind of result I would like but I ran into a couple of issues which stump me a bit on how to solve them:

1.) The CLI service automatically injects basic “browserslist” entries. I want to replace them in my preset (not just extend them). The only way I found to do this is to replace the “api.generator.pkg.browserslist” property in my generator or remove the default entries injected by the cli-service. Replacing it might interfere with other plugins while removing the defaults from the cli-service seems brittle as these defaults might change in the future. What is the recommended way of doing this?

2.) I want to manage every file in the “src” & “public” folder myself. So I create every file at the location I want with the content that I want. There is no setting for a preset to force this behaviour it seems. Even setting “bare” to true, the cli-service and the other plugins I include will create and modify files. I understand that this is desirable for plugins as they need to be composable but a preset should be able to be more authoritative. Currently I check which files are pending to be rendered by passing a callback to the “api.render()” function and delete all keys (which represent the file paths) of the default files I don’t want. After that I have a second call to “render()” passing my “./templates” path. This way I can control which files are created BUT all the other code injections of other plugins e.g. import or dependency injection through “injectImports()” and " injectRootOptions()" still run, polluting my files. Is there a way to work around this?
One use-case here is that I wanted to include the i18n cli plugin by default in the preset but I wanted to move the “./i18n.js” file it generates to a different folder. I can of course include my own “i18n.js” at the location I want and remove the file from the pending renders (or modify the path of the pending renders) but it would still create an import referencing “./i18n.js” which I don’t want.

3.) I used the “onCreateComplete” hook in my generator to overwrite the README but this happens after the repo is setup so it shows the README as an uncommited change. Is there a way to prevent this? (except the “-n” option to “vue create”)

(I also had problems overriding the but there is already a feature-request tracking this.)

I hope some of you have some pointers :slight_smile: Thanks already!

Hey, I got another question:
Is it possible for a preset to programatically add another plugin? So that through prompts of the preset I could ask if a certain feature is wanted and then dynamically add that plugin? I’ve not found such a feature as I would assume it needs special handling (like “invoke”) to trigger the plugins generator, or is just adding it to the dev dependencies enough?