Skip to content

Commit a08d33a

Browse files
authored
Merge pull request #624 from NLeSC/600_validate_package_details
600-validate package details
2 parents d21c1d5 + 6a2ba42 commit a08d33a

6 files changed

Lines changed: 27 additions & 39 deletions

File tree

copier/messages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ _message_after_copy: |
2222
git add --all
2323
git commit -m "first commit"
2424
git branch -M main
25-
git remote add origin {{ repository }}
25+
git remote add origin {{ repository }}.git
2626
2727
- Push the initial commit to a new repo on GitHub
2828

copier/questions/features_publish_release.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ SelectPublishReleaseFeatures:
2323
Zenodo integration instructions:
2424
value: AddZenodo_flag
2525
# validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}"
26-
Package keywords(NOT_IMPLEMENTED):
27-
value: not_implemented_keywords
28-
# validator: "{% if something != 'AnotherThing' %}BlaBla{% endif %}"
29-
3026

3127
# Sub-menus
3228
# split AddCitation --> enable_citation_file and enable_cffconvert
Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,36 @@
11
---
22
# package details
3-
AddPackageDetails:
4-
type: bool
5-
default: yes
6-
help: |-
7-
If you are planning to publish the package it is recommended to provide more details.
8-
Do you want to provide extra details for the package?
9-
when: "{{ template_profile != 'minimum'}}"
3+
# AddPackageDetails:
4+
# type: bool
5+
# default: yes
6+
# help: |-
7+
# If you are planning to publish the package it is recommended to provide more details.
8+
# Do you want to provide extra details for the package?
9+
# when: false
1010
package_short_description:
1111
type: str
1212
placeholder: Short description
1313
help: Short description of package
14-
when: "{{ template_profile != 'minimum' and AddPackageDetails }}"
1514
validator: >-
1615
{% if not package_short_description %}
1716
Package description cannot be empty
1817
{% endif %}
19-
keyword1:
18+
keywords:
2019
type: str
21-
placeholder: keyword1
22-
help: Add keyword1
23-
when: "{{ template_profile != 'minimum' and AddPackageDetails }}"
24-
keyword2:
25-
type: str
26-
placeholder: keyword2
27-
help: Add keyword2
28-
when: "{{ template_profile != 'minimum' and AddPackageDetails }}"
20+
placeholder: keyword1,second keyword,third keyword
21+
help: Add keywords to make your package findable on PyPI
2922
github_organization:
3023
type: str
31-
placeholder: "<my-github-organization>"
24+
placeholder: "your-github-username or your-github-organization"
3225
help: Enter the name of your GitHub username or organization
33-
when: "{{ template_profile != 'minimum' and AddPackageDetails }}"
3426
validator: >-
35-
{% if not github_organization %}
36-
This field cannot be empty
27+
{% if not (github_organization | regex_search('^\\S*$')) %}
28+
Username or organization cannot include spaces
3729
{% endif %}
3830
email:
3931
type: str
4032
placeholder: yourname@esciencecenter.nl
4133
help: What is your email address?
42-
when: "{{ template_profile != 'minimum' and AddPackageDetails }}"
4334
validator: >-
4435
{% if not (email | regex_search('([A-Za-z0-9]+[.-_])*[A-Za-z0-9]+@[A-Za-z0-9-]+(\.[A-Z|a-z]{2,})+')) %}
4536
Please enter a valid email address
@@ -48,22 +39,22 @@ code_of_conduct_email:
4839
type: str
4940
default: "{{ email }}"
5041
help: What is the email address to report code of conduct violations?
51-
when: "{{ template_profile != 'minimum' and AddPackageDetails }}"
5242
validator: >-
5343
{% if not (code_of_conduct_email | regex_search('([A-Za-z0-9]+[.-_])*[A-Za-z0-9]+@[A-Za-z0-9-]+(\.[A-Z|a-z]{2,})+')) %}
5444
Please enter a valid email address
5545
{% endif %}
5646
copyright_holder:
5747
type: str
58-
placeholder: Netherlands eScience Center
59-
help: Who is the copyright holder?
60-
when: "{{ template_profile != 'minimum' and AddPackageDetails }}"
61-
48+
default: "{{ full_name }}"
49+
help: Who is the copyright holder (the default is your full name)?
50+
validator: >-
51+
{% if not copyright_holder %}
52+
This field cannot be empty as it will be used in content of the generated files.
53+
{% endif %}
6254
# calculated fields for GitHub
6355
repository:
6456
default: git@github.com:{{ github_organization }}/{{ package_name }}
6557
when: false
66-
6758
repository_url:
6859
default: https://github.com/{{ github_organization }}/{{ package_name }}
6960
when: false

template/pyproject.toml.jinja

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ classifiers = [
3131
dependencies = []
3232
description = "{{ package_short_description|replace('\"', '\\\"') }}"
3333
keywords = [
34-
"{{ keyword1 }}",
35-
"{{ keyword2 }}",
34+
{%- for item in keywords.split(',') -%}
35+
"{{ item }}"{{ "," if not loop.last }}
36+
{%- endfor -%}
3637
]
3738
license = {file = "LICENSE"}
3839
name = "{{ package_name }}"

template/{% if AddCitation %}CITATION.cff{% endif %}.jinja

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ doi: <insert your DOI here>
1212
version: "{{ version }}"
1313
repository-code: "{{ repository_url }}"
1414
keywords:
15-
- {{ keyword1 }}
16-
- {{ keyword2 }}
15+
{%- for item in keywords.split(',') %}
16+
- "{{ item }}"
17+
{%- endfor %}
1718
message: "If you use this software, please cite it using these metadata."
1819
{{ { "Apache Software License 2.0": "license: Apache-2.0",
1920
"MIT license": "license: MIT",

tests/test_project.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ def copier_project_defaults():
1616
return {
1717
"package_name": "my_python_package",
1818
"package_short_description": "Short description of package",
19-
"keyword1": "keyword1",
20-
"keyword2": "keyword2",
19+
"keywords": "keyword1,keyword2",
2120
"version": "0.1.0",
2221
"github_organization": "<my-github-organization>",
2322
"full_name": "Jane Smith",

0 commit comments

Comments
 (0)