ApeWorX / ape

The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
https://apeworx.io
Apache License 2.0
886 stars 131 forks source link

Merge `ape-template` into core [APE-1219] #1556

Open fubuloubu opened 1 year ago

fubuloubu commented 1 year ago

Overview

https://github.com/cookiecutter/cookiecutter is now actively supported. We we originally prototyped the cookiecutter integration when that package was not being actively supported by it's original author, so we weren't sure if the package was going to be well-supported in the future. However, now it is supported.

ape-template's feature are better off as core functionality, and we should investigate integrating them as a core plugin so that we can leverage it more for other functionality (such as enhancing ape init's default template with additional questions for project setup h/t @pandadefi)

Also found copier, which is an alternative project we could migrate to if needed: https://github.com/ApeWorX/ape-template/issues/9

Specification

Not final, but some ideas of where we can take it once merged:

$ ape init
# Does the same thing it does today, only interactively asking more questions about setup
$ ape init --name "Project Name"  # etc...
# Overloads the template's interactive questions with pre-defined answers
$ ape init gh:ApeAcademy/ERC721
# Use existing `ape-template` functionality to clone a target template

Dependencies

Requires retiring ape-template and updating Ape Academy content to match

antazoey commented 9 months ago

@fubuloubu Are you still wanting this? I added the 0.8 tag.

fubuloubu commented 9 months ago

Yes, I think it's important to have this functionality in Core, and my concerns with cookiecutter are no longer an issue as they are more actively developed now

antazoey commented 9 months ago

Cool, I am thinking when that is done, it will also close https://github.com/ApeWorX/ape/issues/1816, provided the docs are good.

fubuloubu commented 9 months ago

Cool, I am thinking when that is done, it will also close https://github.com/ApeWorX/ape/issues/1816, provided the docs are good.

Yes exactly, should be better able to resolve that issue with some better docs and a few good templates to choose from

antazoey commented 7 months ago

looking at ape-template, it doesnt really do anything. all it does is re-expose the cookiecutter cli. I am not 100% sure what needs to be done here.

fubuloubu commented 7 months ago

looking at ape-template, it doesnt really do anything. all it does is re-expose the cookiecutter cli. I am not 100% sure what needs to be done here.

That is correct, we had it a 2nd party plugin because we were unsure if cookiecutter would continue to be maintained. It is now very active.

The trick would be combining the ape-template functionality with the current ape init functionality so that copying templates using cookiecutter becomes a 1st party feature, and we can leverage it when making tutorials and such (even update the default "empty project" template you get currently via ape init) so as to make Ape more friendly to newcomers


EDIT: The "default template" could be what we do integration testing against to ensure our cookiecutter functionality works out of the box well (the template itself doesn't need to live within this repo)

antazoey commented 7 months ago

It looks like ape init also takes a github argument for cloning a repo (all it does). cookiecutter also takes a github for templating.

question: how would we know if the user is simply wanting to clone a repo versus them wanting to use cookiecutter?

obligatory unwanted opinion: When cloning a repo, people should use tools like git instead of ape. Ape adds overhead for no reason. ape init --github does nothing besides clone a repo. Secondly, I am struggling to see the benefit in using ape over cookiecutter directly. Are we going to subset the types of templates or something?