fast-dev-cli 0.8.0__tar.gz → 0.8.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/PKG-INFO +1 -1
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/fast_dev_cli/cli.py +17 -10
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/pyproject.toml +2 -2
- fast_dev_cli-0.8.1/scripts/test.sh +6 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/tests/test_runserver.py +10 -1
- fast_dev_cli-0.8.0/scripts/test.sh +0 -4
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/LICENSE +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/README.md +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/fast_dev_cli/__init__.py +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/fast_dev_cli/__main__.py +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/fast_dev_cli/py.typed +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/pdm_build.py +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/scripts/check.sh +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/scripts/format.sh +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/tests/__init__.py +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/tests/conftest.py +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/tests/test_bump.py +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/tests/test_fast_test.py +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/tests/test_functions.py +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/tests/test_import.py +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/tests/test_lint.py +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/tests/test_sync.py +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/tests/test_tag.py +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/tests/test_upgrade.py +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/tests/test_upload.py +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/tests/test_version.py +0 -0
- {fast_dev_cli-0.8.0 → fast_dev_cli-0.8.1}/tests/utils.py +0 -0
|
@@ -12,15 +12,13 @@ from typing import TYPE_CHECKING, Literal, Optional, Type
|
|
|
12
12
|
|
|
13
13
|
import typer
|
|
14
14
|
from typer import Exit, Option, echo, secho
|
|
15
|
+
from typing_extensions import Annotated, Self
|
|
15
16
|
|
|
16
17
|
if sys.version_info >= (3, 11):
|
|
17
18
|
from enum import StrEnum
|
|
18
|
-
from typing import Self
|
|
19
19
|
else: # pragma: no cover
|
|
20
20
|
from enum import Enum
|
|
21
21
|
|
|
22
|
-
from typing_extensions import Self
|
|
23
|
-
|
|
24
22
|
class StrEnum(str, Enum):
|
|
25
23
|
__str__ = str.__str__
|
|
26
24
|
|
|
@@ -29,7 +27,7 @@ if TYPE_CHECKING: # pragma: no cover
|
|
|
29
27
|
from typer.models import OptionInfo
|
|
30
28
|
|
|
31
29
|
|
|
32
|
-
__version__ = "0.8.
|
|
30
|
+
__version__ = "0.8.1"
|
|
33
31
|
|
|
34
32
|
|
|
35
33
|
def parse_files(args: list[str] | tuple[str, ...]) -> list[str]:
|
|
@@ -239,27 +237,33 @@ class Project:
|
|
|
239
237
|
path_depth = 5
|
|
240
238
|
|
|
241
239
|
@staticmethod
|
|
242
|
-
def work_dir(name: str, parent: Path, depth: int) -> Path | None:
|
|
240
|
+
def work_dir(name: str, parent: Path, depth: int, be_file=False) -> Path | None:
|
|
243
241
|
for _ in range(depth):
|
|
244
|
-
if parent.joinpath(name).exists():
|
|
242
|
+
if (f := parent.joinpath(name)).exists():
|
|
243
|
+
if be_file:
|
|
244
|
+
return f
|
|
245
245
|
return parent
|
|
246
246
|
parent = parent.parent
|
|
247
247
|
return None
|
|
248
248
|
|
|
249
249
|
@classmethod
|
|
250
250
|
def get_work_dir(
|
|
251
|
-
cls: Type[Self],
|
|
251
|
+
cls: Type[Self],
|
|
252
|
+
name=TOML_FILE,
|
|
253
|
+
cwd: Path | None = None,
|
|
254
|
+
allow_cwd=False,
|
|
255
|
+
be_file=False,
|
|
252
256
|
) -> Path:
|
|
253
257
|
cwd = cwd or Path.cwd()
|
|
254
|
-
if d := cls.work_dir(name, cwd, cls.path_depth):
|
|
258
|
+
if d := cls.work_dir(name, cwd, cls.path_depth, be_file):
|
|
255
259
|
return d
|
|
256
260
|
if allow_cwd:
|
|
257
261
|
return cls.get_root_dir(cwd)
|
|
258
262
|
raise EnvError(f"{name} not found! Make sure this is a poetry project.")
|
|
259
263
|
|
|
260
264
|
@classmethod
|
|
261
|
-
def load_toml_text(cls: Type[Self]) -> str:
|
|
262
|
-
toml_file = cls.get_work_dir()
|
|
265
|
+
def load_toml_text(cls: Type[Self], name=TOML_FILE) -> str:
|
|
266
|
+
toml_file = cls.get_work_dir(name, be_file=True)
|
|
263
267
|
return toml_file.read_text("utf8")
|
|
264
268
|
|
|
265
269
|
@classmethod
|
|
@@ -677,11 +681,14 @@ def dev(
|
|
|
677
681
|
|
|
678
682
|
@cli.command(name="dev")
|
|
679
683
|
def runserver(
|
|
684
|
+
serve_port: Annotated[Optional[int], typer.Argument()] = None,
|
|
680
685
|
port: Optional[int] = Option(None, "-p", "--port"),
|
|
681
686
|
host: Optional[str] = Option(None, "-h", "--host"),
|
|
682
687
|
dry: bool = Option(False, "--dry", help="Only print, not really run shell command"),
|
|
683
688
|
) -> None:
|
|
684
689
|
"""Start a fastapi server(only for fastapi>=0.111.0)"""
|
|
690
|
+
if serve_port:
|
|
691
|
+
port = serve_port
|
|
685
692
|
dev(port, host, dry=dry)
|
|
686
693
|
|
|
687
694
|
|
|
@@ -38,7 +38,7 @@ dependencies = [
|
|
|
38
38
|
"bumpversion >=0.6.0,<0.7",
|
|
39
39
|
"pytest >=8.2.0,<9",
|
|
40
40
|
]
|
|
41
|
-
version = "0.8.
|
|
41
|
+
version = "0.8.1"
|
|
42
42
|
|
|
43
43
|
[project.urls]
|
|
44
44
|
Homepage = "https://github.com/waketzheng/fast-dev-cli"
|
|
@@ -66,7 +66,7 @@ source-includes = [
|
|
|
66
66
|
|
|
67
67
|
[tool.pdm.dev-dependencies]
|
|
68
68
|
dev = [
|
|
69
|
-
"-e file:///${PROJECT_ROOT}/#egg=fast-dev-cli[
|
|
69
|
+
"-e file:///${PROJECT_ROOT}/#egg=fast-dev-cli[all]",
|
|
70
70
|
]
|
|
71
71
|
|
|
72
72
|
[tool.waketzheng._internal-slim-build.packages.fastdevcli-slim.project]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from fast_dev_cli.cli import dev, runserver
|
|
1
|
+
from fast_dev_cli.cli import dev, run_and_echo, runserver
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
def test_runserver(capsys):
|
|
@@ -35,3 +35,12 @@ def test_dev(capsys):
|
|
|
35
35
|
dev(port=9000, host="0.0.0.0", dry=True)
|
|
36
36
|
out = capsys.readouterr().out.strip()
|
|
37
37
|
assert "fastapi dev --port=9000 --host=0.0.0.0" == out.replace("--> ", "")
|
|
38
|
+
dev(8001, host="0.0.0.0", dry=True)
|
|
39
|
+
out = capsys.readouterr().out.strip()
|
|
40
|
+
assert "fastapi dev --port=8001 --host=0.0.0.0" == out.replace("--> ", "")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def test_fast_dev(tmp_path):
|
|
44
|
+
out = tmp_path / "a.txt"
|
|
45
|
+
run_and_echo(f"fast dev 9000 --dry > {out}", verbose=False)
|
|
46
|
+
assert "fastapi dev --port=9000" in out.read_text()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|