Skip to content

Commit ef57d74

Browse files
feat: ✨ add post-copy commands to run (#101)
# Description These changes add some commands to run right after copying from the template. Closes #95 This PR needs a quick review. ## Checklist - [x] Formatted Markdown - [x] Ran `just run-all` --------- Co-authored-by: martonvago <57952344+martonvago@users.noreply.github.com>
1 parent c3068ae commit ef57d74

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,10 @@ jobs:
2424
- name: Install justfile and zsh
2525
run: sudo apt install -y just zsh
2626

27+
- name: Set Git user
28+
run: |
29+
git config --global user.name "GitHub Actions"
30+
git config --global user.email "fake@example.com"
31+
2732
- name: Test and check template creation
2833
run: just test

README.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,43 @@ on what is included in this template.
99

1010
## Using this template
1111

12-
We strongly recommend using this template with
13-
[uv](https://docs.astral.sh/uv/). Once you have it installed, move into
14-
the directory where you want to create the new Data Package and run the
15-
following command:
12+
You need these programs installed in order to use this template.
13+
14+
- [Git](https://git-scm.com/)
15+
- [Python](https://www.python.org/)
16+
- [uv](https://docs.astral.sh/uv/)
17+
- [just](https://just.systems/man/en/)
18+
19+
Once you have these installed, open a terminal and move into the directory
20+
where you want to create the new Data Package and run the following command:
1621

1722
``` bash
1823
# Copy into the current directory with "."
19-
uvx copier copy gh:seedcase-project/template-data-package .
24+
uvx copier copy --trust gh:seedcase-project/template-data-package .
2025
```
2126

27+
> [!CAUTION]
28+
> This template runs some post-copy commands using your terminal. In order
29+
> to run them, you need to use the `--trust` option. Review the
30+
> [`copier.yml`](copier.yaml) file, under the `_tasks` key to see what
31+
> commands will be run after copying the template, so you can know and trust
32+
> what the commands are doing. Unfortunately, this template can't be used
33+
> without the `--trust` option.
34+
2235
### Post-creation setup
2336

2437
These steps are mainly for us in the Seedcase Project to set up the
2538
repository with the settings we use, but you can follow them if you want
2639
to set up your Data Package in a similar way.
2740

28-
Install [`spaid`](https://github.com/seedcase-project/spaid) and use the
41+
After copying the template, while in the directory of the new Data Package,
42+
run the following:
43+
44+
``` bash
45+
just install-precommit
46+
```
47+
48+
Next, install [`spaid`](https://github.com/seedcase-project/spaid) and use the
2949
following commands to run the next setup steps:
3050

3151
``` bash

copier.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
_subdirectory: template
22

3+
# Post-copy commands:
4+
_tasks:
5+
# Only run these commands when copying the template
6+
- command: "git init -b main"
7+
when: "{{ _copier_operation == 'copy' }}"
8+
- command: "uv add --dev pre-commit commitizen ruff typos"
9+
when: "{{ _copier_operation == 'copy' }}"
10+
- command: "uv add polars seedcase-sprout"
11+
when: "{{ _copier_operation == 'copy' }}"
12+
- command: "git add ."
13+
when: "{{ _copier_operation == 'copy' }}"
14+
- command: "git commit -m 'chore: :tada: setup a new data package from the template'"
15+
when: "{{ _copier_operation == 'copy' }}"
16+
317
# Questions:
418
package_github_repo:
519
type: str

justfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ test:
3939
# `.` means the current directory contains the template.
4040
uvx copier copy --vcs-ref=HEAD . $test_dir/$test_name \
4141
--defaults \
42+
--trust \
4243
--data package_abbrev=$test_name \
4344
--data package_github_repo="first-last/${test_name}" \
4445
--data author_given_name="First" \

0 commit comments

Comments
 (0)