Skip to content

Commit 75f062e

Browse files
committed
Make copier input robust against bad project names
Also reduce length of validation message as copier's statusline provided by the prompt_toolkit is limited to one line.
1 parent 833549f commit 75f062e

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ The format is inspired by [Keep a Changelog](https://keepachangelog.com/en/1.1.0
6161
- `just gen-project` tolerates a missing `project/` directory. #161
6262
- Generated YAML files (GitHub Actions, mkdocs) and `test_data.py` now pass
6363
default yamllint/ruff checks. #170
64-
- `just _update-linkml` uses `uv lock` instead of `uv add` to avoid side-effect of adding linkml as main dependency. #159
64+
- Reject invalid `project_name` input (e.g. trailing dot, single character) at
65+
the prompt with a friendly message instead of crashing later.
66+
- `just _update-linkml` uses `uv lock` instead of `uv add` to avoid side-effect
67+
of adding linkml as main dependency. #159
6568
- Force-push to `gh-pages` during docs deployment to avoid history conflicts. #154
6669
- Align `uv sync` invocation in template workflows. #150
6770
- Skip ShEx integration test on Python 3.13 and install dependencies in the
@@ -145,7 +148,7 @@ The format is inspired by [Keep a Changelog](https://keepachangelog.com/en/1.1.0
145148
### Added
146149

147150
- New pre-commit command that updates the uv.lock file. #81
148-
- Automatic publishing of releases to Zenodo ([doi:10.5281/zenodo.15163584](https://doi.org/10.5281/zenodo.15163584)). #
151+
- Automatic publishing of releases to Zenodo ([doi:10.5281/zenodo.15163584](https://doi.org/10.5281/zenodo.15163584)).
149152

150153
### Fixed
151154

copier.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ project_name:
99
type: str
1010
help: What is your project name?
1111
default: my-awesome-schema
12+
# Catch invalid input and show a friendly message.
13+
validator: >-
14+
{% if not (project_name | regex_search('^[A-Za-z][A-Za-z0-9 _\-]*[A-Za-z0-9]$',
15+
ignorecase=False)) %}
16+
Use 2+ of letters, digits, space, '-', '_'; start with letter, end alnum.
17+
{% endif %}
1218
1319
project_slug:
1420
type: str
@@ -22,8 +28,7 @@ project_slug:
2228
validator: >-
2329
{% if not (project_slug | regex_search('^[a-z][_a-z0-9\-]+$',
2430
ignorecase=False)) %}
25-
project_slug must start with a lowercase letter, followed by lowercase
26-
letters, digits, dashes or underscores.
31+
Start with a lowercase letter, then lowercase letters, digits, '-' or '_'.
2732
{% endif %}
2833
2934
email:

0 commit comments

Comments
 (0)