Skip to content

Commit a0bf7ad

Browse files
authored
refactor: 🔥 simplify the Copier questions by removing many of them (#278)
# Description Many of the questions can be replaced with TODO items. This simplifies the template implementation as there are less Jinja variables to keep track of. Needs no review. ## Checklist - [x] Ran `just run-all`
1 parent 75a4a39 commit a0bf7ad

11 files changed

Lines changed: 101 additions & 115 deletions

‎copier.yaml‎

Lines changed: 18 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,41 @@
1-
_subdirectory: template
1+
_subdirectory: "template"
22

33
# Message to show after generating or regenerating the project successfully
44
_message_after_copy: |
55
6-
Your project "{{ github_repo }}" has been created successfully!
6+
Your project "{{ github_repo }}" has been created successfully! See
7+
the template's guide as well as the "TODO.md" file in the newly created
8+
project for more details on the next steps.
79
8-
See the [guide](https://template-python-package.seedcase-project.org/docs/guide) for more detail
9-
on the next steps. Briefly:
10-
11-
1. Change directory to the project root:
12-
13-
``` bash
14-
cd {{ _copier_conf.dst_path | realpath }}
15-
```
16-
17-
2. Install the pre-commit hooks, add (called "update" here) the Quarto extension,
18-
and build the README:
19-
20-
``` bash
21-
just install-precommit update-quarto-theme build-readme
22-
```
23-
24-
3. Install [`spaid`](https://github.com/seedcase-project/spaid) and run these setup steps:
25-
26-
``` bash
27-
spaid_gh_create_repo_from_local -h
28-
spaid_gh_set_repo_settings -h
29-
spaid_gh_ruleset_basic_protect_main -h
30-
```
31-
32-
4. Configure GitHub following this
33-
[guide](https://guidebook.seedcase-project.org/operations/security#using-github-apps-to-generate-tokens):
34-
35-
- Install the [auto-release-token](https://github.com/apps/auto-release-token)
36-
and [add-to-board-token](https://github.com/apps/add-to-board-token) GitHub Apps
37-
- Create an `UPDATE_VERSION_TOKEN` and `ADD_TO_BOARD_TOKEN` secret for the GitHub Apps
38-
- Create an `UPDATE_VERSION_APP_ID` and `ADD_TO_BOARD_APP_ID` variable of the GitHub Apps' IDs
39-
40-
5. List and complete all TODO items in the repository:
41-
42-
``` bash
43-
just list-todos
44-
```
45-
46-
# Questions:
47-
is_seedcase_project:
10+
# Questions
11+
for_seedcase:
4812
type: bool
4913
help: "Is this package part of the Seedcase Project?"
50-
default: true
14+
default: false
5115

5216
github_user:
5317
type: str
54-
help: "What is the name of the GitHub user or organisation where the repository will be or is stored?"
55-
default: "{{ 'seedcase-project' if is_seedcase_project else '' }}"
18+
help: |
19+
What is the name of the GitHub user or organization where the
20+
package repository will be or is stored?
21+
default: >-
22+
{{ "seedcase-project" if for_seedcase else "" }}
5623
5724
github_repo:
5825
type: str
59-
help: "What is the name of the GitHub repository where the website will be or is stored? We strongly recommend using the default given."
26+
help: |
27+
What is the name of the GitHub repository where the package will be or
28+
is stored? We strongly recommend using the default given.
6029
default: "{{ _folder_name }}"
6130

6231
hosting_provider:
6332
type: str
64-
help: "What hosting provider will you use for the documentation website?"
33+
help: "What hosting provider will you use for the package's website?"
6534
choices:
6635
- netlify
6736
- gh-pages
68-
69-
author_given_name:
70-
type: str
71-
help: "What is your first/given name?"
72-
73-
author_family_name:
74-
type: str
75-
help: "What is your last/family name?"
76-
77-
author_email:
78-
type: str
79-
help: "What is your email address?"
80-
81-
review_team:
82-
type: str
83-
help: What GitHub team is responsible for reviewing pull requests?
84-
default: "{{ '@%s/developers' % github_user if github_user else '' }}"
85-
86-
github_board_number:
87-
type: str
88-
help: "What is the GitHub project board number to add issues and PRs to?"
89-
validator: |
90-
{% if github_board_number and not github_board_number.isdigit() %}
91-
The board number must be an integer.
92-
{% endif %}
37+
default: >-
38+
{{ "netlify" if for_seedcase else "gh-pages" }}
9339
9440
# Configurations not asked
9541
github_repo_snake_case:
@@ -106,8 +52,3 @@ copyright_year:
10652
type: str
10753
default: "{{ copyright_year | default('%Y' | strftime) }}"
10854
when: false
109-
110-
homepage:
111-
type: str
112-
default: "https://{{ github_repo }}.{{ github_user }}.org"
113-
when: false

‎justfile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ format-md:
5353
uvx rumdl fmt --silent **/*.qmd.jinja **/*.md.jinja
5454

5555
# Test template creation with specific parameters: LIST
56-
test is_seedcase_project="true" hosting_provider="netlify":
57-
sh ./test-template.sh {{ is_seedcase_project }} {{ hosting_provider }}
56+
test for_seedcase="true" hosting_provider="netlify":
57+
sh ./test-template.sh {{ for_seedcase }} {{ hosting_provider }}
5858

5959
# Test template creation through use of the question approach
6060
test-manual:

‎template/.github/workflows/add-to-project.yml.jinja‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ jobs:
2020
permissions:
2121
pull-requests: write
2222
with:
23-
board-number: {{ github_board_number }}
23+
# TODO: Fill in the board number.
24+
board-number: ""
2425
app-id: {{ '${{ vars.ADD_TO_BOARD_APP_ID }}' }}
2526
secrets:
2627
add-to-board-token: {{ '${{ secrets.ADD_TO_BOARD }}' }}

‎template/404.qmd.jinja‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
---
2-
{% if is_seedcase_project -%}
2+
{% if for_seedcase -%}
33
title: "You've entered the garden of missing pages"
44
{% else -%}
55
title: "The page you are looking for does not exist"
66
{% endif -%}
77
---
88

9-
{% if is_seedcase_project -%}
9+
{% if for_seedcase -%}
1010
Let's get you back to greener grounds.
1111

1212
👉 Go to [homepage](/index.qmd).
1313

14-
![](/_extensions/seedcase-project/seedcase-theme/images/404.svg){fig-alt="An illustration of the number 404 surrounded by trees and mountains"}
14+
![](/_extensions/seedcase-project/seedcase-theme/images/404.svg){fig-alt="An
15+
illustration of the number 404 surrounded by trees and mountains"}
1516

1617
## Illustration by [Storyset](https://storyset.com/online) {.appendix}
18+
1719
{%- else -%}
18-
This page does not exist, go back to the [homepage](/index.qmd) or check the URL for typos.
20+
This page does not exist, go back to the [homepage](/index.qmd) or check
21+
the URL for typos.
1922
{%- endif %}

‎template/CITATION.cff.jinja‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ title: ""
33
# TODO: Add abstract of Python package.
44
abstract: ""
55
authors:
6-
- family-names: {{ author_family_name }}
7-
given-names: {{ author_given_name }}
8-
# TODO: Add ORCID and affiliation for the author.
6+
# TODO: Add author information.
7+
- family-names: ""
8+
given-names: ""
99
orcid: ""
1010
affiliation: ""
1111
# TODO: Add more authors as needed.
@@ -22,5 +22,5 @@ keywords:
2222
license: MIT
2323
message: "If you use this Python package, please cite it using these metadata."
2424
repository-code: "https://github.com/{{ github_repo_spec }}"
25-
# TODO: Confirm URL
26-
url: "{{ homepage }}"
25+
# TODO: Add URL to a website.
26+
url: ""

‎template/CONTRIBUTING.md.jinja‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ issue on our GitHub repository.
99

1010
## :pencil2: Adding or modifying content
1111

12-
{% if is_seedcase_project -%}
12+
{% if for_seedcase -%}
1313
If you would like to contribute content, please check out our
1414
[guidebook](https://guidebook.seedcase-project.org/) for more specific
1515
details on how we work and develop. It is a regularly evolving document,

‎template/TODO.md‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
- Review the
2+
[template guide](https://t-squared.seedcase-project.org/docs/guide/)
3+
for more information on how to use the template and the next steps
4+
after copying the project.
5+
- Run `git init -b main` to create the project as a Git repository.
6+
- Install these packages
7+
`uv add --dev pre-commit ruff typos pytest bandit commitizen genbadge jupyter pytest-cov quartodoc types-tabulate mypy vulture`
8+
- Run `just list-todos` and complete all the TODO items.
9+
- Run `just install-precommit` to install the pre-commit hooks.
10+
- Run `just build-readme` to build the Markdown version of the README.
11+
{%- if for_seedcase -%}
12+
- Run `just update-quarto-theme` to add the Seedcase Quarto extension.
13+
- Install the [`spaid`](https://github.com/seedcase-project/spaid) CLI
14+
tool and run these setup steps:
15+
- `spaid_gh_create_repo_from_local -h` to create a GitHub repository
16+
from the local repository.
17+
- `spaid_gh_set_repo_settings -h` to set the repository settings.
18+
- `spaid_gh_ruleset_basic_protect_main -h` to protect the main branch.
19+
- `spaid_gh_ruleset_require_pr -h` to require pull requests for
20+
changes to the main branch.
21+
- Install or add the
22+
[auto-release-token](https://github.com/apps/auto-release-token) and
23+
[add-to-board-token](https://github.com/apps/add-to-board-token)
24+
GitHub Apps
25+
- Create an `UPDATE_VERSION_TOKEN` and `ADD_TO_BOARD_TOKEN` secret for
26+
the GitHub Apps if you haven't already and connect them to the
27+
repository.
28+
- Create an `UPDATE_VERSION_APP_ID` and `ADD_TO_BOARD_APP_ID` variable
29+
of the GitHub Apps' IDs if you haven't already and connect them to
30+
the repository.
31+
{%- else -%}
32+
- Install the [gh CLI](https://cli.github.com/) to create the GitHub
33+
repository from the command line by using
34+
`gh repo create {{ github_repo_spec }} --source=. --public`.
35+
{%- endif %}
36+
{% if hosting_provider == "netlify" %}
37+
- Connect the repository to Netlify and turn off the builds on Netlify,
38+
since you will be using GitHub Actions to build and deploy the
39+
website.
40+
{%- elif hosting_provider == "gh-pages" -%}
41+
- Run `quarto publish gh-pages` to setup and start publishing the
42+
website to GitHub Pages.
43+
{%- endif %}
44+
- If relevant, connect [GoatCounter](https://www.goatcounter.com/).
45+
- If relevant, connect [pre-commit.ci](https://pre-commit.ci/) to the
46+
repository and enable the pre-commit hooks.

‎template/_quarto.yml.jinja‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ website:
1616
navbar:
1717
pinned: true
1818
title: false
19-
{%- if is_seedcase_project %}
19+
{%- if for_seedcase %}
2020
logo: "_extensions/seedcase-project/seedcase-theme/logos/{{ github_repo }}/navbar.svg"
2121
logo-alt: "{{ github_repo }} logo: Main page"
2222
{%- else %}
@@ -37,7 +37,7 @@ website:
3737
- icon: github
3838
href: "https://github.com/{{ github_repo_spec }}"
3939
aria-label: "GitHub icon: Source code"
40-
{%- if is_seedcase_project %}
40+
{%- if for_seedcase %}
4141
- icon: house
4242
href: "https://seedcase-project.org"
4343
aria-label: "House icon: Main website for the Seedcase Project"
@@ -75,7 +75,7 @@ metadata-files:
7575
- docs/reference/_sidebar.yml
7676

7777
format:
78-
{% if is_seedcase_project -%}
78+
{% if for_seedcase -%}
7979
seedcase-theme-html:
8080
theme:
8181
- brand

‎template/justfile.jinja‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@_builds: build-contributors build-website build-readme
99

1010
# Run all build-related recipes in the justfile
11-
{%- if is_seedcase_project %}
11+
{%- if for_seedcase %}
1212
run-all: install-deps update-quarto-theme format-python format-md _checks _tests _builds
1313
{%- else %}
1414
run-all: install-deps format-python _checks _tests _builds
@@ -32,7 +32,7 @@ install-precommit:
3232
# Update versions of pre-commit hooks
3333
uvx pre-commit autoupdate
3434

35-
{%- if is_seedcase_project %}
35+
{%- if for_seedcase %}
3636
# Update the Quarto seedcase-theme extension
3737
update-quarto-theme:
3838
# Add theme if it doesn't exist, update if it does

‎template/pyproject.toml.jinja‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ version = "0.1.0"
44
# TODO: Add a description of the package.
55
description = ""
66
authors = [
7-
{name = "{{ author_given_name }} {{ author_family_name }}", email = "{{ author_email }}" },
8-
# TODO: Add more authors as needed.
7+
# TODO: Add author information.
8+
{name = "FIRST LAST", email = "" },
99
]
1010
maintainers = [
11-
{name = "{{ author_given_name }} {{ author_family_name }}", email = "{{ author_email }}" },
12-
# TODO: Add more maintainers as needed.
11+
# TODO: Add maintainer information.
12+
{name = "FIRST LAST", email = "" },
1313
]
1414
readme = "README.md"
1515
license = "MIT"
@@ -18,8 +18,8 @@ requires-python = ">=3.12"
1818
dependencies = []
1919

2020
[project.urls]
21-
# TODO: Confirm URL
22-
homepage = "{{ homepage }}"
21+
# TODO: Add URLs relevant to the project.
22+
homepage = ""
2323
repository = "https://github.com/{{ github_repo_spec }}"
2424
changelog = "https://github.com/{{ github_repo_spec }}/blob/main/CHANGELOG.md"
2525
issues = "https://github.com/{{ github_repo_spec }}/issues"

0 commit comments

Comments
 (0)