Closed mws-github closed 2 months ago
When the cookiecutter template is nested within a repository, like in your example (https://github.com/aws/industry-toolkit/tree/main/templates/servers/java-spring-boot/{{cookiecutter.project_name}}), there are a few ways to work around this, as cookiecutter expects the template to be at the root of the repository by default.
Here are some approaches you can use to access the nested template:
bash Copy code git clone https://github.com/aws/industry-toolkit cd industry-toolkit/templates/servers/java-spring-boot cookiecutter . This approach works well if you’re okay with cloning the whole repository locally.
Navigate to the nested template folder on GitHub (e.g., templates/servers/java-spring-boot). Download that directory as a ZIP, or clone just that part of the repo using sparse checkout. Run: bash Copy code cookiecutter /path/to/extracted/folder
bash Copy code git init industry-toolkit cd industry-toolkit git remote add origin https://github.com/aws/industry-toolkit.git git config core.sparseCheckout true echo "templates/servers/java-spring-boot/" >> .git/info/sparse-checkout git pull origin main cd templates/servers/java-spring-boot cookiecutter . This will only pull the templates/servers/java-spring-boot directory, allowing you to avoid downloading the entire repository.
Summary If the template is nested in a repository, the key options are:
Clone the repository and navigate to the nested folder to run cookiecutter. Use git sparse-checkout to clone only the template folder. Manually download the template files and run cookiecutter locally. Each option ensures that you can properly use a nested template without needing to restructure the repository.
Our toolkit will take 2 parameters:
The tooling will handle the downloading of the template.
Just tried to build a new project with the Spring template, but failed. Am I referencing the the template the wrong way from the command line?
Local Build Log
C:\temp\cookie-playground>cookiecutter https://github.com/aws/industry-toolkit/tree/main/templates/servers/java-spring-boot/%7B%7Bcookiecutter.project_name%7D%7D The repository https://github.com/aws/industry-toolkit/tree/main/templates/servers/java-spring-boot/%7B%7Bcookiecutter.project_name%7D%7D could not be found, have you made a typo?