fast-dev-cli 0.23.0__tar.gz → 0.23.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.
Files changed (30) hide show
  1. {fast_dev_cli-0.23.0 → fast_dev_cli-0.23.1}/PKG-INFO +1 -1
  2. fast_dev_cli-0.23.1/fast_dev_cli/__init__.py +1 -0
  3. {fast_dev_cli-0.23.0 → fast_dev_cli-0.23.1}/fast_dev_cli/cli.py +66 -50
  4. {fast_dev_cli-0.23.0 → fast_dev_cli-0.23.1}/pyproject.toml +11 -2
  5. fast_dev_cli-0.23.0/fast_dev_cli/__init__.py +0 -1
  6. fast_dev_cli-0.23.0/tests/__init__.py +0 -0
  7. fast_dev_cli-0.23.0/tests/assets/uv-tx.lock +0 -1476
  8. fast_dev_cli-0.23.0/tests/assets/uv-upload-time.lock +0 -1658
  9. fast_dev_cli-0.23.0/tests/assets/uv.lock +0 -1476
  10. fast_dev_cli-0.23.0/tests/conftest.py +0 -59
  11. fast_dev_cli-0.23.0/tests/test_bump.py +0 -424
  12. fast_dev_cli-0.23.0/tests/test_deps.py +0 -102
  13. fast_dev_cli-0.23.0/tests/test_exec.py +0 -51
  14. fast_dev_cli-0.23.0/tests/test_fast_test.py +0 -115
  15. fast_dev_cli-0.23.0/tests/test_functions.py +0 -119
  16. fast_dev_cli-0.23.0/tests/test_help.py +0 -7
  17. fast_dev_cli-0.23.0/tests/test_lint.py +0 -474
  18. fast_dev_cli-0.23.0/tests/test_poetry_version_plugin.py +0 -102
  19. fast_dev_cli-0.23.0/tests/test_pypi.py +0 -118
  20. fast_dev_cli-0.23.0/tests/test_runserver.py +0 -136
  21. fast_dev_cli-0.23.0/tests/test_sync.py +0 -240
  22. fast_dev_cli-0.23.0/tests/test_tag.py +0 -73
  23. fast_dev_cli-0.23.0/tests/test_upgrade.py +0 -322
  24. fast_dev_cli-0.23.0/tests/test_upload.py +0 -43
  25. fast_dev_cli-0.23.0/tests/test_version.py +0 -78
  26. fast_dev_cli-0.23.0/tests/utils.py +0 -74
  27. {fast_dev_cli-0.23.0 → fast_dev_cli-0.23.1}/LICENSE +0 -0
  28. {fast_dev_cli-0.23.0 → fast_dev_cli-0.23.1}/README.md +0 -0
  29. {fast_dev_cli-0.23.0 → fast_dev_cli-0.23.1}/fast_dev_cli/__main__.py +0 -0
  30. {fast_dev_cli-0.23.0 → fast_dev_cli-0.23.1}/fast_dev_cli/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fast-dev-cli
3
- Version: 0.23.0
3
+ Version: 0.23.1
4
4
  Summary: Python project development tool.
5
5
  Author-Email: Waket Zheng <waketzheng@gmail.com>>
6
6
  Classifier: Development Status :: 4 - Beta
@@ -0,0 +1 @@
1
+ __version__ = "0.23.1"
@@ -738,6 +738,12 @@ class Project:
738
738
  if t in backend:
739
739
  cls._tool = t
740
740
  return cls._tool
741
+ return cls._get_manage_tool(text, backend, skip_uv)
742
+
743
+ @classmethod
744
+ def _get_manage_tool(
745
+ cls: type[Self], text: str, backend: str, skip_uv: bool
746
+ ) -> ToolName | None:
741
747
  work_dir: Path | None = None
742
748
  uv_lock_exists: bool | None = None
743
749
  if skip_uv:
@@ -762,6 +768,12 @@ class Project:
762
768
  if uv_lock_exists:
763
769
  cls._tool = "uv"
764
770
  return cls._tool
771
+ return cls._parse_manage_tool(work_dir, text, backend)
772
+
773
+ @classmethod
774
+ def _parse_manage_tool(
775
+ cls: type[Self], work_dir: Path, text: str, backend: str
776
+ ) -> ToolName | None:
765
777
  pdm_lock_exists = Path(work_dir, "pdm.lock").exists()
766
778
  poetry_lock_exists = Path(work_dir, "poetry.lock").exists()
767
779
  match pdm_lock_exists + poetry_lock_exists:
@@ -1576,6 +1588,59 @@ def should_use_just() -> bool:
1576
1588
  return False
1577
1589
 
1578
1590
 
1591
+ def _parse_serve_file(uvicorn, filename: str, cmd: str, args: list) -> str:
1592
+ if m := re.search(r"(.*):(\d+)$", filename):
1593
+ h, p = m.group(1), m.group(2)
1594
+ if h and "--host" not in str(args):
1595
+ if h == "0":
1596
+ args.append("--host=0.0.0.0")
1597
+ else:
1598
+ args.append(f"--host={h}")
1599
+ args.append(f"--port={p}")
1600
+ if uvicorn:
1601
+ p = Path("main.py")
1602
+ if p.exists():
1603
+ cmd += " main:app"
1604
+ elif Path("app", p.name).exists():
1605
+ cmd += " app.main:app"
1606
+ elif Path("app.py").exists():
1607
+ cmd += " app:app"
1608
+ return cmd
1609
+ if uvicorn and ((filepath := Path(filename)).is_file() or filepath.suffix == ".py"):
1610
+ filename = filepath.stem + ":app"
1611
+ parent_names = [j for i in filepath.parents if (j := i.name)]
1612
+ if parent_names:
1613
+ filename = ".".join([*parent_names[::-1], filename])
1614
+ cmd += " " + filename
1615
+ return cmd
1616
+
1617
+
1618
+ def _runserver(uvicorn, host, port, file) -> tuple[str, list[str]]:
1619
+ cmd = "uvicorn" if uvicorn else "fastapi dev"
1620
+ args = []
1621
+ if (host := getattr(host, "default", host)) and host not in (
1622
+ "localhost",
1623
+ "127.0.0.1",
1624
+ ):
1625
+ args.append(f"--host={host}")
1626
+ no_port_yet = True
1627
+ if file is not None:
1628
+ filename = str(file)
1629
+ try:
1630
+ port = int(filename)
1631
+ except ValueError:
1632
+ cmd = _parse_serve_file(uvicorn, filename, cmd, args)
1633
+ else:
1634
+ if port != 8000:
1635
+ args.append(f"--port={port}")
1636
+ no_port_yet = False
1637
+ if no_port_yet and (port := getattr(port, "default", port)) and str(port) != "8000":
1638
+ args.append(f"--port={port}")
1639
+ if shutil.which("pdm") is not None:
1640
+ cmd = "pdm run " + cmd
1641
+ return cmd, args
1642
+
1643
+
1579
1644
  def dev(
1580
1645
  port: int | None | OptionInfo,
1581
1646
  host: str | None | OptionInfo,
@@ -1590,56 +1655,7 @@ def dev(
1590
1655
  args = [i for i in sys.argv[2:] if i != "--dry"]
1591
1656
  cmd = "just dev"
1592
1657
  else:
1593
- cmd = "uvicorn" if uvicorn else "fastapi dev"
1594
- args = []
1595
- if (host := getattr(host, "default", host)) and host not in (
1596
- "localhost",
1597
- "127.0.0.1",
1598
- ):
1599
- args.append(f"--host={host}")
1600
- no_port_yet = True
1601
- if file is not None:
1602
- try:
1603
- port = int(str(file))
1604
- except ValueError:
1605
- if m := re.search(r"(.*):(\d+)$", str(file)):
1606
- h, p = m.group(1), m.group(2)
1607
- if h and "--host" not in str(args):
1608
- if h == "0":
1609
- args.append("--host=0.0.0.0")
1610
- else:
1611
- args.append(f"--host={h}")
1612
- args.append(f"--port={p}")
1613
- if uvicorn:
1614
- p = Path("main.py")
1615
- if p.exists():
1616
- cmd += " main:app"
1617
- elif Path("app", p.name).exists():
1618
- cmd += " app.main:app"
1619
- elif Path("app.py").exists():
1620
- cmd += " app:app"
1621
- else:
1622
- if uvicorn and (
1623
- (filepath := Path(str(file))).is_file()
1624
- or filepath.suffix == ".py"
1625
- ):
1626
- file = filepath.stem + ":app"
1627
- parent_names = [j for i in filepath.parents if (j := i.name)]
1628
- if parent_names:
1629
- file = ".".join([*parent_names[::-1], file])
1630
- cmd += f" {file}"
1631
- else:
1632
- if port != 8000:
1633
- args.append(f"--port={port}")
1634
- no_port_yet = False
1635
- if (
1636
- no_port_yet
1637
- and (port := getattr(port, "default", port))
1638
- and str(port) != "8000"
1639
- ):
1640
- args.append(f"--port={port}")
1641
- if shutil.which("pdm") is not None:
1642
- cmd = "pdm run " + cmd
1658
+ cmd, args = _runserver(uvicorn, host, port, file)
1643
1659
  if args:
1644
1660
  cmd += " " + " ".join(args)
1645
1661
  exit_if_run_failed(cmd, dry=dry)
@@ -29,7 +29,7 @@ dependencies = [
29
29
  "typer>=0.24.0,<1",
30
30
  "tomli >=2.0.1,<3; python_version < '3.11'",
31
31
  ]
32
- version = "0.23.0"
32
+ version = "0.23.1"
33
33
 
34
34
  [project.urls]
35
35
  Homepage = "https://github.com/waketzheng/fast-dev-cli"
@@ -65,9 +65,18 @@ build-backend = "pdm.backend"
65
65
  distribution = true
66
66
 
67
67
  [tool.pdm.version]
68
- source = "file"
69
68
  path = "fast_dev_cli/__init__.py"
70
69
 
70
+ [tool.pdm.build]
71
+ excludes = [
72
+ "./**/.git",
73
+ "./**/.*_cache",
74
+ "examples",
75
+ "scripts",
76
+ "tests",
77
+ "fastdevcli-slim",
78
+ ]
79
+
71
80
  [tool.pdm.scripts]
72
81
  up = "just up {args}"
73
82
  tree = "pdm list --tree {args}"
@@ -1 +0,0 @@
1
- __version__ = "0.23.0"
File without changes