Skip to content

Commit b568f37

Browse files
committed
refactor: ♻️ match template-website copier setup
1 parent 265bcaa commit b568f37

14 files changed

Lines changed: 83 additions & 68 deletions

copier.yaml

Lines changed: 29 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,26 @@ _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

5248
github_user:
5349
type: str
54-
default: "{{ package_github_repo.split('/')[0] if package_github_repo else '' }}"
55-
when: false
50+
help: "What is the name of the GitHub user or organization where the website repository will be or is stored?"
5651

57-
package_name:
52+
hosting_provider:
5853
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' }}"
54+
help: "What hosting provider will you use for the documentation website?"
55+
choices:
56+
- netlify
57+
- gh-pages
7558

7659
homepage:
7760
type: str
7861
help: "What is the homepage of your project?"
79-
default: "{{ 'https://%s.seedcase-project.org' % package_name if is_seedcase_project else '' }}"
62+
default: "{{ 'https://%s.seedcase-project.org' % github_repo if is_seedcase_project else '' }}"
8063

8164
author_given_name:
8265
type: str
@@ -103,6 +86,23 @@ github_board_number:
10386
The board number must be an integer.
10487
{% endif %}
10588
89+
# Configurations not asked
90+
91+
github_repo:
92+
type: str
93+
default: "{{ _copier_conf.dst_path | realpath | basename }}"
94+
when: false
95+
96+
github_repo_snake_case:
97+
type: str
98+
default: "{{github_repo | replace('-', '_') | replace('.', '_')}}"
99+
when: false
100+
101+
github_repo_spec:
102+
type: str
103+
default: "{{ github_user }}/{{ github_repo }}"
104+
when: false
105+
106106
copyright_year:
107107
type: str
108108
default: "{{ copyright_year | default('%Y' | strftime) }}"

justfile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
@_checks: check-spelling check-commits
55
# Test Seedcase and non-Seedcase projects
6-
@_tests: (test "true") (test "false")
6+
@_tests: (test "true" "netlify") (test "false" "netlify") (test "true" "gh-pages") (test "false" "gh-pages")
77
@_builds: build-contributors build-website build-readme
88

99
# Run all build-related recipes in the justfile
@@ -47,7 +47,7 @@ check-spelling:
4747
uvx typos
4848

4949
# Test and check that a Python package can be created from the template
50-
test is_seedcase_project:
50+
test is_seedcase_project="true" hosting_provider="netlify":
5151
#!/bin/zsh
5252
test_name="test-python-package"
5353
test_dir="$(pwd)/_temp/{{ is_seedcase_project }}/$test_name"
@@ -59,8 +59,9 @@ test is_seedcase_project:
5959
--vcs-ref=$commit \
6060
--defaults \
6161
--trust \
62-
--data package_github_repo="first-last/repo" \
6362
--data is_seedcase_project={{ is_seedcase_project }} \
63+
--data github_user="first-last" \
64+
--data hosting_provider={{ hosting_provider }} \
6465
--data author_given_name="First" \
6566
--data author_family_name="Last" \
6667
--data author_email="first.last@example.com" \
@@ -93,8 +94,9 @@ test is_seedcase_project:
9394
--defaults \
9495
--trust \
9596
--overwrite \
96-
--data package_github_repo="first-last/repo" \
9797
--data is_seedcase_project={{ is_seedcase_project }} \
98+
--data github_user="first-last" \
99+
--data hosting_provider={{ hosting_provider }} \
98100
--data author_given_name="First" \
99101
--data author_family_name="Last" \
100102
--data author_email="first.last@example.com" \

template/.github/workflows/build-website.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build website
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
# Limit token permissions for security
9+
permissions: read-all
10+
11+
jobs:
12+
build-website:
13+
uses: seedcase-project/.github/.github/workflows/reusable-build-docs-with-python.yml@main
14+
{% if hosting_provider == 'gh-pages' -%}
15+
with:
16+
hosting-provider: gh-pages
17+
permissions:
18+
contents: write
19+
pages: write
20+
{%- endif %}
21+
secrets:
22+
{% if hosting_provider == 'gh-pages' -%}
23+
github-token: {{ '${{ secrets.GITHUB_TOKEN }}' }}
24+
{%- elif hosting_provider == 'netlify' -%}
25+
netlify-token: {{ '${{ secrets.NETLIFY_AUTH_TOKEN }}' }}
26+
{%- endif %}

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/README.md.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
# {{ package_name }}
3+
# {{ github_repo }}

template/README.qmd.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
# {{ package_name }}
1+
# {{ github_repo }}
22

33
<!-- TODO: Add README for project. -->

template/_quarto.yml.jinja

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,25 @@ project:
99
website:
1010
# TODO: Fill in the title of the website.
1111
title: ""
12+
{% if hosting_provider == "gh-pages" -%}
13+
site-url: "https://{{ github_user }}.github.io/{{ github_repo }}/"
14+
{%- elif hosting_provider == "netlify" -%}
15+
# TODO: Set the Netlify custom domain URL
16+
site-url: ""
17+
{%- endif %}
1218
site-url: "{{ homepage }}"
13-
repo-url: "https://github.com/{{ package_github_repo }}"
19+
repo-url: "https://github.com/{{ github_repo_spec }}"
1420
page-navigation: true
1521
navbar:
1622
pinned: true
1723
title: false
1824
{%- if is_seedcase_project %}
19-
logo: "_extensions/seedcase-project/seedcase-theme/logos/navbar-logo-{{ package_name }}.svg"
20-
logo-alt: "{{ package_name }} logo: Main page"
25+
logo: "_extensions/seedcase-project/seedcase-theme/logos/navbar-logo-{{ github_repo }}.svg"
26+
logo-alt: "{{ github_repo }} logo: Main page"
2127
{%- else %}
2228
# TODO: add logo
2329
logo: ""
24-
logo-alt: "{{ package_name }} logo: Main page"
30+
logo-alt: "{{ github_repo }} logo: Main page"
2531
{%- endif %}
2632
left:
2733
- text: "Guide"
@@ -30,7 +36,7 @@ website:
3036
href: docs/design/index.qmd
3137
tools:
3238
- icon: github
33-
href: "https://github.com/{{ package_github_repo }}"
39+
href: "https://github.com/{{ github_repo_spec }}"
3440
aria-label: "GitHub icon: Source code"
3541
{% if is_seedcase_project -%}
3642
- icon: house
@@ -53,7 +59,7 @@ quartodoc:
5359
sidebar: "docs/reference/_sidebar.yml"
5460
style: "pkgdown"
5561
dir: "docs/reference"
56-
package: "{{ package_name_snake_case }}"
62+
package: "{{ github_repo_snake_case }}"
5763
parser: google
5864
dynamic: true
5965
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>

0 commit comments

Comments
 (0)