Skip to content

Commit 82b8eeb

Browse files
Prepare for 0.0.5
1 parent d8026ab commit 82b8eeb

File tree

16 files changed

+117
-82
lines changed

16 files changed

+117
-82
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[flake8]
22
exclude = __pycache__,built,build,venv
3-
ignore = E203, E266, W503
3+
ignore = E203, E266, W503, E704
44
max-line-length = 88
55
max-complexity = 18
66
select = B,C,E,F,W,T4,B9

.github/workflows/build.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
python-version: [3.8, 3.9, "3.10", "3.11"]
23+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2424

2525
steps:
2626
- uses: actions/checkout@v1
@@ -35,8 +35,7 @@ jobs:
3535

3636
- name: Install dependencies
3737
run: |
38-
pip install -e .
39-
pip install isort flake8 black pytest pytest-cov
38+
pip install -r dev-requirements.txt
4039
4140
- name: Run tests
4241
run: |
@@ -46,7 +45,6 @@ jobs:
4645
run: |
4746
echo "Running linters"
4847
49-
pip install black
5048
flake8 .
5149
isort --check-only . 2>&1
5250
black --check . 2>&1
@@ -67,34 +65,34 @@ jobs:
6765
rm -rf junit
6866
rm -rf deps
6967
pip install build
70-
if: matrix.python-version == 3.11
68+
if: matrix.python-version == 3.12
7169

7270
- name: Create distribution package
7371
run: python -m build
74-
if: matrix.python-version == 3.11
72+
if: matrix.python-version == 3.12
7573

7674
- name: Upload distribution package
77-
uses: actions/upload-artifact@master
75+
uses: actions/upload-artifact@v4
7876
with:
7977
name: dist
8078
path: dist
81-
if: matrix.python-version == 3.11
79+
if: matrix.python-version == 3.12
8280

8381
publish:
8482
runs-on: ubuntu-latest
8583
needs: build
8684
if: github.event_name == 'release'
8785
steps:
8886
- name: Download a distribution artifact
89-
uses: actions/download-artifact@v2
87+
uses: actions/download-artifact@v4
9088
with:
9189
name: dist
9290
path: dist
9391

94-
- name: Use Python 3.11
92+
- name: Use Python 3.12
9593
uses: actions/setup-python@v1
9694
with:
97-
python-version: '3.11'
95+
python-version: '3.12'
9896

9997
- name: Install dependencies
10098
run: |

CHANGELOG.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,30 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.0.5] - 2025-03-29
9+
10+
- Add the `--checkout` option to the `create` command to support using specific
11+
branches and tags. Example:
12+
`blacksheep create my-proj2 --template mvc --checkout v1.0.2`.
13+
- Add support for `int` and `float` question types (to enable budget
14+
validation).
15+
- Add missing `__init__.py` files.
16+
- Update dependencies, apply latest formatting from `black`.
17+
- Workflow maintenance.
18+
- Remove Python 3.8 from the build matrix, add Python 3.12 and 3.13.
19+
820
## [0.0.4] - 2023-08-20 :sun_with_face:
921

10-
- Adds support for Git repositories cloned over SSH.
11-
- Adds support for Cookiecutter [directories](https://cookiecutter.readthedocs.io/en/stable/cli_options.html#cmdoption-cookiecutter-directory).
22+
- Add support for Git repositories cloned over SSH.
23+
- Add support for Cookiecutter [directories](https://cookiecutter.readthedocs.io/en/stable/cli_options.html#cmdoption-cookiecutter-directory).
1224

1325
## [0.0.3] - 2023-06-28 :wrench:
1426

15-
- Adds support for conditional questions.
27+
- Add support for conditional questions.
1628

1729
## [0.0.2] - 2023-06-28 :hammer:
1830

19-
- Corrects error when stopping a template questionary.
31+
- Correct error when stopping a template questionary.
2032

2133
## [0.0.1] - 2023-06-27 :gem:
2234

README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,41 @@
88
pip install blacksheep-cli
99
```
1010

11+
```bash
12+
blacksheep --help
13+
14+
blacksheep create --help
15+
```
16+
1117
## Official project templates
1218

13-
- `api`, to scaffold Web API projects
19+
- `api`, to scaffold Web API projects.
1420
- `mvc`, to scaffold Web Apps projects with Model, View, Controller
15-
architecture, including Server Side Rendering of HTML views (SSR)
21+
architecture, including Server Side Rendering of HTML views (SSR).
1622

1723
## Creating a new project
1824

1925
```bash
2026
blacksheep create
2127
```
2228

29+
Create a project pinned to a specific tag:
30+
31+
```bash
32+
blacksheep create Example --template mvc --checkout v1.0.2
33+
```
34+
35+
Tags refer to the project template repository. To see the list of tags, use the
36+
`blacksheep templates details` and navigate to the URL of the template
37+
repository.
38+
2339
## Listing the project templates
2440

2541
```bash
2642
blacksheep templates list
2743
```
2844

29-
With details:
45+
See details about the templates:
3046

3147
```bash
3248
blacksheep templates details

blacksheepcli/__init__.py

Whitespace-only changes.

blacksheepcli/common/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Rich click increases import times and it might be desirable to disable it (e.g. when
44
running automated jobs).
55
"""
6+
67
import os
78

89
_disable_rich = os.environ.get("NORICH_CLI", "").lower() in {

blacksheepcli/common/cookiemod.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Main entry point for the `cookiecutter` command, modified to support prompting the user
33
with Python https://github.com/tmbo/questionary, to offer a better user experience.
44
"""
5+
56
import logging
67
import os
78
import sys

blacksheepcli/common/prompts.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,43 @@
33
questionary (as it gives better control and a better user experience than cookiecutter's
44
built-in prompt support).
55
"""
6+
67
import json
78
from pathlib import Path
89

910

11+
def _is_float(value):
12+
try:
13+
float(value)
14+
return True
15+
except ValueError:
16+
return False
17+
18+
19+
_TYPES = {
20+
"int": {
21+
"validate": lambda x: x.isdigit(),
22+
},
23+
"float": {
24+
"validate": _is_float,
25+
},
26+
}
27+
28+
29+
def _normalize_type(item):
30+
"""
31+
Normalize the type to support more scenarios that are not supported by Python
32+
questionary.
33+
34+
https://questionary.readthedocs.io/en/stable/
35+
"""
36+
type_ = item.get("type")
37+
38+
if type_ in _TYPES:
39+
item["type"] = "text"
40+
item.update(_TYPES[type_])
41+
42+
1043
def _normalize_required(item):
1144
required = item.get("required")
1245

@@ -39,6 +72,7 @@ def _normalize_when(item):
3972

4073
def normalize_questions(extra_context, data):
4174
for item in data:
75+
_normalize_type(item)
4276
_normalize_required(item)
4377
_normalize_when(item)
4478

blacksheepcli/create/cli.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,17 @@ def print_instructions(destination: str):
4040
help="Project template name.",
4141
required=False,
4242
)
43+
@click.option(
44+
"--checkout",
45+
"-c",
46+
help="Optional tag or branch name to use with the project template.",
47+
required=False,
48+
)
4349
def create_project(
4450
name: Optional[str] = None,
4551
destination: Optional[str] = None,
4652
template: Optional[str] = None,
53+
checkout: Optional[str] = None,
4754
):
4855
"""
4956
Create a new project, with the given NAME, from a template.
@@ -52,7 +59,9 @@ def create_project(
5259
5360
blacksheep create my-proj
5461
55-
blacksheep create my-proj --template basic
62+
blacksheep create my-proj --template mvc
63+
64+
blacksheep create my-proj --template mvc --checkout v1.0.2
5665
"""
5766
while not name:
5867
# unsafe_ask because we let Click handle user cancellation
@@ -74,7 +83,7 @@ def create_project(
7483
assert destination is not None
7584
ProjectManager().bootstrap(
7685
template_obj.source,
77-
template_obj.tag or None,
86+
checkout or template_obj.tag or None,
7887
template_obj.folder,
7988
{"project_name": name},
8089
)

blacksheepcli/templates/data/default.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
This module provides the default implementation of TemplatesDataProvider, which uses a
33
JSON file stored in a user's folder.
44
"""
5+
56
import json
67
import os
78
from dataclasses import asdict

0 commit comments

Comments
 (0)