-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
copier.yml
196 lines (168 loc) · 7.45 KB
/
copier.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# Copier configuration settings
_subdirectory: template
_min_copier_version: "9.1.0"
_message_after_copy: |
Your package "{{ name }}" has been created successfully!
Next steps:
1. (Optional) Ensure that git is initialized in the project root, if not:
$ git init
2. Generate a poetry.lock file:
$ make lock
3. Read README.md and start coding.
#######################################################################################################################
# 1. Questions for the package maintainers
#######################################################################################################################
name:
type: str
help: What is the package name?
validator: >-
{% if not name %}
Name is required.
{% elif not (name | regex_search('^[a-zA-Z](?:[a-zA-Z0-9]| (?![ ]))*$')) %}
Only alphanumeric characters and single spaces are allowed.
{% endif %}
description:
type: str
help: What does the package do?
placeholder: "A Python package that ..."
package_type:
type: str
help: What package type do you want to create?
choices:
Python Package: package
Django App: django
FastAPI App: fastapi
Gradio App: gradio
Streamlit App: streamlit
default: package
use_pydantic:
type: bool
help: Do you want to use Pydantic (y/N)?
default: "{% if package_type == 'fastapi' %}yes{% else %}no{% endif %}"
when: "{{ package_type != 'fastapi' }}"
use_makefile:
type: bool
help: Do you want to use a Makefile with convenient shortcuts (y/N)?
default: no
#######################################################################################################################
# 1.2 Setup CI/CD
#######################################################################################################################
ci:
type: str
help: What Continuous Integration service do you want to use?
choices:
GitHub CI: github
GitLab CI: gitlab
No CI: none
default: github
repository_url:
type: str
help: What is the URL of this repository?
default: "{% if ci == 'github' %}https://github.com/<username>/<repo>/{% else %}https://gitlab.com/<username>/<repo>/{% endif %}"
validator: >-
{% if ci == 'github' and not (repository_url | trim | regex_search('^https://github\\.com/[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+/$')) %}
Invalid GitHub URL, example: https://github.com/lukin0110/poetry-copier-fastapi-demo/
{% elif ci == 'gitlab' and not (repository_url | regex_search('^https://gitlab\\.com/[a-zA-Z0-9/_-]+/$')) %}
Invalid GitHub URL, example: https://gitlab.com/lukin0110/poetry-copier-fastapi-gitlab-demo/
{% elif not repository_url %}
Repository URL is required.
{% endif %}
# 1.2.1 Configure private package repository
use_private_package_repository:
type: bool
help: Use a private package repository to download proprietary packages (y/N)?
default: no
private_package_repository_name:
type: str
help: What is the name of the private package repository?
default: "private_pypi"
when: "{{ use_private_package_repository }}"
validator: "{% if not (private_package_repository_name | regex_search('^[a-zA-Z_]+$')) %}Invalid repository name{% endif %}"
private_package_repository_url:
type: str
help: What is the URL of the private gitlab package repository?
default: "{% if ci == 'gitlab' %}https://gitlab.com/api/v4/projects/<project_id>/packages/pypi/simple{% else %}https://<private-pypi-url>/simple{% endif %}"
when: "{{ use_private_package_repository }}"
validator: >-
{% if use_private_package_repository %}
{% if ci == 'gitlab' and not (private_package_repository_url | regex_search('https://gitlab.com/api/v4/projects/[0-9]+/packages/pypi/simple')) %}
Invalid GitLab URL for private package repository, example: https://gitlab.com/api/v4/projects/1234/packages/pypi/simple
{% elif not private_package_repository_url | regex_search('^https:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(\/[^\s]*)?$') %}
Invalid URL for private package repository, example: https://private-pypi.org/simple
{% elif not private_package_repository_url %}
Private repository URL is required.
{% endif %}
{% endif %}
# 1.2.2 Configure package publishing
use_private_publish_repository:
type: bool
help: Use a private package repository to publish this package to (y/N)?
default: no
when: "{{ package_type == 'package' }}"
private_publish_repository_url:
type: str
help: URL of the private package repository to publish this package to?
default: "{% if ci == 'gitlab' %}https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi{% else %}https://<private-pypi-url>{% endif %}"
when: "{{ use_private_publish_repository }}"
validator: >-
{% if use_private_publish_repository %}
{% if ci == 'gitlab' and not (private_publish_repository_url | regex_search('https://gitlab.com/api/v4/projects/.+/packages/pypi')) %}
Invalid GitLab URL to publish, example: https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi
{% elif not private_publish_repository_url | regex_search('^https:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(\/[^\s]*)?$') %}
Invalid URL for private publish repository, example: https://private-pypi.org/simple
{% elif not private_publish_repository_url %}
Private publish repository URL is required.
{% endif %}
{% endif %}
# 1.2.3 Setup GitHub CI/CD
# TODO: setup private package support (https://github.com/lukin0110/poetry-copier/issues/17)
#######################################################################################################################
# 2. Computed or fixed values
# Compute, don't prompt. https://github.com/copier-org/copier/issues/716#issuecomment-1263307193
#######################################################################################################################
python_version:
type: str
help: What Python version do you want to use?
default: "3.13.0"
when: false
poetry_version:
type: str
help: What Poetry version do you want to use?
default: "1.8.4"
when: false
# The validator of the `name` field ensures that the name only contains alphanumeric characters and single spaces.
package_slug:
type: str
help: A slug of the package name?
default: "{{ name | lower | trim | replace(' ', '_') }}"
when: false
use_app:
type: bool
help: Do you want to use the app (y/N)?
default: "{% if package_type != 'package' %}yes{% else %}no{% endif %}"
when: false
use_django:
type: bool
help: Do you want to use Django (y/N)?
default: "{% if package_type == 'django' %}yes{% else %}no{% endif %}"
when: false
use_fastapi:
type: bool
help: Do you want to use FastAPI (y/N)?
default: "{% if package_type == 'fastapi' %}yes{% else %}no{% endif %}"
when: false
use_gradio:
type: bool
help: Do you want to use Gradio (y/N)?
default: "{% if package_type == 'gradio' %}yes{% else %}no{% endif %}"
when: false
use_streamlit:
type: bool
help: Do you want to use Streamlit (y/N)?
default: "{% if package_type == 'streamlit' %}yes{% else %}no{% endif %}"
when: false
use_push_ecr:
type: bool
help: Do you want to push the Docker image to ECR (y/N)?
default: no
when: false