[GSoC-2023] Customizable(and interactive) package templates proposal

Thank you so much for your reply, Ashley. First of all, I would love to work with you!

I fully agree that the swift package template command should be used to store the template in a fixed location, so that it can be used directly when initializing in the future (e.g. swift package init). And the --template option seems completely unnecessary, after all it does the same thing as --type. I am sorry that the design is so complicated and unnecessary.

Sure, I think tweaking is definitely needed, this is only the simplest version implemented for demonstration purposes.

After thinking about it, I also think that such a format is not necessary. The reason I thought so is that in the official idea list (probably written by boris), it says "In this project, we will define a format for templates", which I thought was a way to package all the code and folders in a project into a single file. In fact, a zip file with a template.json file describing the interactivity (e.g., specifying the location of the test folder) would solve the problem perfectly, and would be much simpler to use.

I am sorry for this design mistake, as I started writing the proposal very late due to health issues, so I did not get enough feedback.

If that's so, there is only one use for this command, swift package template </path/to/your/project>, that is to copy the project as a template into a pre-defined fixed location for the user to call init later. As for sharing, users can just send zip files to each other directly. (just like downloading a template from some iOS App Templates websites) The only thing that is worth mentioning is that the root path of the project can contain a template.json file for possible interactions.

I'm sorry to have to say that I don't know. I don't think it's so difficult to write Package.swift files by hand that you need to include dependencies interactively. Moreover, when users can design their own templates, they can modify the Package.swift file first and then use the swift package template to store it for future use. If you say that writing Package.swift is too difficult for newcomers, it is better to include dependencies interactively, but how will newcomers know which dependencies to include, and which not to include? So I don't think interactive include dependencies is a necessary feature. Sorry, I'm kinda limited by the description in the idea list.

Definitely, I think this is the best approach. Customize is entirely the user's job and swiftPM only helps store it in a fixed place for quick initialization, with some interactivity like whether to add the test folder or not.

Of course, I'll write up a markdown file and make it available soon.

Thank you very much, although I think most of my proposals are too complex and lack practicality, I am sorry for not thinking about the problem properly, and I promise to iterate quickly.

Also, I don't really understand what real practical interactivity there is, other than whether to include the test folder or not. I'll create a post asking for opinions on the forum.

1 Like