Skip to content

Commit 123bb3c

Browse files
committed
♻️ Improve template structure
We had set up the template to have a `{{ plugin_name }}` directory at the root of the `template` directory. The idea was that a user can just `copier copy` the template in the current directory and it would automatically create a full directory structure for the plugin package, where the root directory of the package would always match the module directory in the `src`. However, this creates issues when we want to start using `copier update`. Ideally, we'd be able to use the previous answers stored in the `.copier-answers.yml` file. However, this is created in the root directory of the template by `copier`. So it would be created in the parent directory of our actual package with the current set up. This means a user can not just go inside the `plugin_name` directory and run `copier update`. We've looked for workarounds based on copying the `.copier-answers.yml` file inside the `plugin_name` directory post `copier copy`, but they all were deemed messy, fragile and perhaps even not fully functional. Instead, we restructured the template by: 1. Removing the `{{ plugin_name }}` subdirectory in the `template` directory, instead moving its contents into the root `template` directory. 2. Using the `copier copy` `destination_path` (retrievable via `_copier_conf.dst_path`) for the default of the `plugin_name` input. This means the user can now run: copier copy https://github.com/mbercx/aiida-plugin-copier <plugin_name> and use the defaults to generate a new plugin package in the `<plugin_name>` directory.
1 parent a73e054 commit 123bb3c

File tree

14 files changed

+7
-6
lines changed

14 files changed

+7
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Follow the [`copier` installation instructions](https://copier.readthedocs.io/en
88
Then simply run
99

1010
```
11-
copier copy https://github.com/mbercx/aiida-plugin-copier .
11+
copier copy https://github.com/mbercx/aiida-plugin-copier <plugin_name>
1212
```
1313

1414
And answer the questions to generate a new AiiDA plugin package in the current directory.

copier.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugin_name:
22
type: str
33
help: 'What is the name of your plugin package?'
4+
default: '{{ _copier_conf.dst_path | basename }}'
45

56
description:
67
type: str

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Follow the [`copier` installation instructions](https://copier.readthedocs.io/en
88
Then simply run
99

1010
```
11-
copier copy https://github.com/mbercx/aiida-plugin-copier .
11+
copier copy https://github.com/mbercx/aiida-plugin-copier <plugin_name>
1212
```
1313

1414
And answer the questions to generate a new AiiDA plugin package in the current directory.

pyproject.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@ dependencies = [
44
"uv"
55
]
66
scripts.copy = [
7-
"copier copy . {args:.tmp} -f -d plugin_name=aiida-test",
7+
"copier copy . {args:.tmp} -f",
88
]
99
scripts.install = [
10-
"copier copy . .tmp -f -d plugin_name=aiida-test",
10+
"copier copy . .tmp/aiida-test -f",
1111
"uv pip install .tmp/aiida-test",
1212
]
1313
scripts.check = [
14-
"copier copy . .tmp -f -d plugin_name=aiida-test",
14+
"copier copy . .tmp/aiida-test -f",
1515
"hatch fmt -l --check .tmp/aiida-test",
1616
]
1717
scripts.docs = [
18-
"copier copy . .tmp -f -d plugin_name=aiida-test",
18+
"copier copy . .tmp/aiida-test -f",
1919
"cd .tmp/aiida-test/docs && myst start",
2020
]
2121
scripts.clean = [
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)