alvis / presetter

🛹 Reuse and manage build scripts, devDependencies and config files from your favourite presets, instead of copy and paste!
MIT License
68 stars 2 forks source link

questions about creating a preset #1

Closed faassen closed 3 years ago

faassen commented 3 years ago

I discovered presetter yesterday and today we played with it. I'm excited about a tool that can turn boilerplate into a reusable package! I have a few questions and comments; my apologies if issues are not the right channel for it.

I looked at the sample preset. Unfortunately it contains quite a bit of code, which makes it somewhat difficult to comprehend what is essential for a preset and what is incidental. I think I understand from the documentation that the essential contract is quite minimal, but it's hard to see. I think a very minimal preset that just contains one config file, a single development dependency and a single script would be very helpful.

The example preset offers a particular system for managing configuration files as yaml files and then converting them into a json format, with the option for overrides. I think it would be interesting to consider extracting this and create a reusable package that presets can build on. That would be another way to make the example preset less intimidating as well.

My first reaction is to wonder why the files are maintained in the yaml format while they are generated as JSON. It makes it harder for me to recognize familiar configuration files. Is this because with yaml you can address overrides in a convenient manner? It won't work for all possible configuration files as not everything is expressed as JSON; I see for npmignore there's a special system for a list-based config.

I spent a bit of time looking for a way to interpolate template variables, but I didn't find any. While most config files don't need a variables, in some cases it would be very useful to be able to refer to the repository or package name within a particular config file. Perhaps the system could even automatically extract this from package.json and make it available.

In the example preset I don't see any examples of configuration that is stored in a directory. husky is an example of such a configuration system. Does presetter support this? Another use case is to store github actions configuration in .github in a preset.

Finally I have a question about the way scripts are integrated. We noticed that when running a script it would modify the package.json and then after run replace it again with the original version. I saw that you mention in the FAQ what to do if that fails and leaves the package.json changed by accident. I was trying to understand why modifying the scripts section is necessary in the first place. Why can't presetter run work without this modification? Is this because it needs those scripts to exist to allow executing them exactly as if they were really in the source code? It'd be nice if there were a way to issue commands programmatically in the same context as scripts.

Thanks again for producing this very interesting tool! I'm going to experiment with it some more.