Skip to content

Commit 2fb9f27

Browse files
authored
refactor: ♻️ match copier vars in template-website (#152)
1 parent 3835ada commit 2fb9f27

File tree

10 files changed

+37
-47
lines changed

10 files changed

+37
-47
lines changed

copier.yaml

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ _tasks:
99
# Message to show after generating or regenerating the project successfully
1010
_message_after_copy: |
1111
12-
Your project "{{ package_name }}" has been created successfully!
12+
Your project "{{ github_repo }}" has been created successfully!
1313
1414
Next steps:
1515
@@ -40,43 +40,25 @@ _message_after_copy: |
4040
$ just list-todos
4141
4242
# Questions:
43-
package_github_repo:
44-
type: str
45-
help: "What is or will be the GitHub repository spec for the project?"
46-
placeholder: "user/repo"
47-
validator: |
48-
{% if package_github_repo and not (package_github_repo | regex_search('^[\w.-]+\/[\w.-]+$')) %}
49-
Must be in the format `user/repo` and contain only alphanumeric characters and `_`, `-`, or `.`.
50-
{% endif %}
43+
is_seedcase_project:
44+
type: bool
45+
help: "Is this package part of the Seedcase Project?"
46+
default: true
5147

52-
github_user:
48+
github_repo:
5349
type: str
54-
default: "{{ package_github_repo.split('/')[0] if package_github_repo else '' }}"
50+
default: "{{ _copier_conf.dst_path | realpath | basename }}"
5551
when: false
5652

57-
package_name:
53+
github_user:
5854
type: str
59-
help: "What is the name of the package?"
60-
default: "{{ _copier_conf.dst_path | basename }}"
61-
validator: |
62-
{% if package_name and not (package_name | regex_search('^[\w.-]+$')) %}
63-
Must contain only alphanumeric characters and `_`, `-`, or `.`.
64-
{% endif %}
65-
66-
package_name_snake_case:
67-
type: str
68-
default: "{{package_name | replace('-', '_') | replace('.', '_')}}"
69-
when: false
70-
71-
is_seedcase_project:
72-
type: bool
73-
help: "Is this package part of the Seedcase Project?"
74-
default: "{{ github_user == 'seedcase-project' }}"
55+
help: "What is the name of the GitHub user or organisation where the repository will be or is stored?"
56+
default: "{{ 'seedcase-project' if is_seedcase_project else '' }}"
7557

7658
homepage:
7759
type: str
7860
help: "What is the homepage of your project?"
79-
default: "{{ 'https://%s.seedcase-project.org' % package_name if is_seedcase_project else '' }}"
61+
default: "{{ 'https://%s.seedcase-project.org' % github_repo if is_seedcase_project else '' }}"
8062

8163
author_given_name:
8264
type: str
@@ -103,6 +85,16 @@ github_board_number:
10385
The board number must be an integer.
10486
{% endif %}
10587
88+
github_repo_snake_case:
89+
type: str
90+
default: "{{github_repo | replace('-', '_') | replace('.', '_')}}"
91+
when: false
92+
93+
github_repo_spec:
94+
type: str
95+
default: "{{ github_user }}/{{ github_repo }}"
96+
when: false
97+
10698
copyright_year:
10799
type: str
108100
default: "{{ copyright_year | default('%Y' | strftime) }}"

justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ test is_seedcase_project:
6060
--vcs-ref=$commit \
6161
--defaults \
6262
--trust \
63-
--data package_github_repo="first-last/repo" \
6463
--data is_seedcase_project={{ is_seedcase_project }} \
64+
--data github_user="first-last" \
6565
--data author_given_name="First" \
6666
--data author_family_name="Last" \
6767
--data author_email="[email protected]" \
@@ -94,8 +94,8 @@ test is_seedcase_project:
9494
--defaults \
9595
--trust \
9696
--overwrite \
97-
--data package_github_repo="first-last/repo" \
9897
--data is_seedcase_project={{ is_seedcase_project }} \
98+
--data github_user="first-last" \
9999
--data author_given_name="First" \
100100
--data author_family_name="Last" \
101101
--data author_email="[email protected]" \

template/CITATION.cff.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ keywords:
2020
- ""
2121
license: MIT
2222
message: "If you use this Python package, please cite it using these metadata."
23-
repository-code: "https://github.com/{{ package_github_repo }}"
23+
repository-code: "https://github.com/{{ github_repo_spec }}"
2424
url: "{{ homepage }}"

template/LICENSE.md.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MIT License
22

3-
Copyright (c) {{ copyright_year }} {{ package_name }} authors
3+
Copyright (c) {{ copyright_year }} {{ github_repo }} authors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

template/_quarto.yml.jinja

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ website:
1212
# TODO: Fill in the title of the website.
1313
title: ""
1414
site-url: "{{ homepage }}"
15-
repo-url: "https://github.com/{{ package_github_repo }}"
15+
repo-url: "https://github.com/{{ github_repo_spec }}"
1616
page-navigation: true
1717
navbar:
1818
pinned: true
1919
title: false
2020
{%- if is_seedcase_project %}
21-
logo: "_extensions/seedcase-project/seedcase-theme/logos/navbar-logo-{{ package_name }}.svg"
22-
logo-alt: "{{ package_name }} logo: Main page"
21+
logo: "_extensions/seedcase-project/seedcase-theme/logos/navbar-logo-{{ github_repo }}.svg"
22+
logo-alt: "{{ github_repo }} logo: Main page"
2323
{%- else %}
2424
# TODO: add logo
2525
logo: ""
26-
logo-alt: "{{ package_name }} logo: Main page"
26+
logo-alt: "{{ github_repo }} logo: Main page"
2727
{%- endif %}
2828
left:
2929
- text: "Guide"
@@ -32,7 +32,7 @@ website:
3232
href: docs/design/index.qmd
3333
tools:
3434
- icon: github
35-
href: "https://github.com/{{ package_github_repo }}"
35+
href: "https://github.com/{{ github_repo_spec }}"
3636
aria-label: "GitHub icon: Source code"
3737
{%- if is_seedcase_project %}
3838
- icon: house
@@ -55,7 +55,7 @@ quartodoc:
5555
sidebar: "docs/reference/_sidebar.yml"
5656
style: "pkgdown"
5757
dir: "docs/reference"
58-
package: "{{ package_name_snake_case }}"
58+
package: "{{ github_repo_snake_case }}"
5959
parser: google
6060
dynamic: true
6161
renderer:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<!-- TODO: Set up GoatCounter -->
2-
<script data-goatcounter="https://{{ github_user }}-{{ package_name }}.goatcounter.com/count" async
2+
<script data-goatcounter="https://{{ github_user }}-{{ github_repo }}.goatcounter.com/count" async
33
src="//gc.zgo.at/count.js"></script>

template/justfile.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ build-readme:
112112

113113
# Generate a Quarto include file with the contributors
114114
build-contributors:
115-
sh ./tools/get-contributors.sh {{ package_github_repo }}
115+
sh ./tools/get-contributors.sh {{ github_repo_spec }}
116116

117117
# Check for and apply updates from the template
118118
update-from-template:

template/pyproject.toml.jinja

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[project]
2-
name = "{{ package_name }}"
2+
name = "{{ github_repo }}"
33
version = "0.1.0"
44
# TODO: Add a description of the package.
55
description = ""
@@ -19,11 +19,9 @@ dependencies = []
1919

2020
[project.urls]
2121
homepage = "{{ homepage }}"
22-
{%- if package_github_repo %}
23-
repository = "https://github.com/{{ package_github_repo }}"
24-
changelog = "https://github.com/{{ package_github_repo }}/blob/main/CHANGELOG.md"
25-
issues = "https://github.com/{{ package_github_repo }}/issues"
26-
{% endif %}
22+
repository = "https://github.com/{{ github_repo_spec }}"
23+
changelog = "https://github.com/{{ github_repo_spec }}/blob/main/CHANGELOG.md"
24+
issues = "https://github.com/{{ github_repo_spec }}/issues"
2725

2826
[build-system]
2927
requires = ["hatchling"]

0 commit comments

Comments
 (0)