fast-dev-cli 0.16.0__tar.gz → 0.16.2__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.16.0 → fast_dev_cli-0.16.2}/PKG-INFO +1 -1
- fast_dev_cli-0.16.2/fast_dev_cli/__init__.py +1 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/fast_dev_cli/cli.py +21 -4
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/pyproject.toml +47 -9
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/tests/test_bump.py +43 -3
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/tests/test_tag.py +5 -3
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/tests/test_upgrade.py +2 -2
- fast_dev_cli-0.16.0/fast_dev_cli/__init__.py +0 -1
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/LICENSE +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/README.md +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/fast_dev_cli/__main__.py +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/fast_dev_cli/py.typed +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/pdm_build.py +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/scripts/check.py +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/scripts/format.py +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/scripts/test.py +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/tests/__init__.py +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/tests/conftest.py +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/tests/test_fast_test.py +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/tests/test_functions.py +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/tests/test_lint.py +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/tests/test_poetry_version_plugin.py +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/tests/test_runserver.py +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/tests/test_sync.py +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/tests/test_upload.py +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/tests/test_version.py +0 -0
- {fast_dev_cli-0.16.0 → fast_dev_cli-0.16.2}/tests/utils.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.16.2"
|
|
@@ -190,9 +190,13 @@ def get_current_version(
|
|
|
190
190
|
work_dir = Project.get_work_dir()
|
|
191
191
|
package_name = re.sub(r"[- ]", "_", work_dir.name)
|
|
192
192
|
try:
|
|
193
|
-
|
|
193
|
+
installed_version = importlib_metadata.version(package_name)
|
|
194
194
|
except importlib_metadata.PackageNotFoundError:
|
|
195
|
-
|
|
195
|
+
...
|
|
196
|
+
else:
|
|
197
|
+
if installed_version != "0.0.0":
|
|
198
|
+
return installed_version
|
|
199
|
+
return read_version_from_file(package_name, work_dir)
|
|
196
200
|
|
|
197
201
|
cmd = ["poetry", "version", "-s"]
|
|
198
202
|
if verbose:
|
|
@@ -409,6 +413,8 @@ class BumpUp(DryRun):
|
|
|
409
413
|
cmd += " && git push && git push --tags && git log -1"
|
|
410
414
|
else:
|
|
411
415
|
cmd += " --allow-dirty"
|
|
416
|
+
if Project.is_pdm_project():
|
|
417
|
+
cmd = "pdm sync --prod && " + cmd
|
|
412
418
|
return cmd
|
|
413
419
|
|
|
414
420
|
def run(self: Self) -> None:
|
|
@@ -524,6 +530,15 @@ class Project:
|
|
|
524
530
|
root = venv_parent
|
|
525
531
|
return root
|
|
526
532
|
|
|
533
|
+
@classmethod
|
|
534
|
+
def is_pdm_project(cls, strict: bool = True) -> bool:
|
|
535
|
+
if cls.get_manage_tool() != "pdm":
|
|
536
|
+
return False
|
|
537
|
+
if strict:
|
|
538
|
+
lock_file = cls.get_work_dir() / "pdm.lock"
|
|
539
|
+
return lock_file.exists()
|
|
540
|
+
return True
|
|
541
|
+
|
|
527
542
|
|
|
528
543
|
class ParseError(Exception):
|
|
529
544
|
"""Raise this if parse dependence line error"""
|
|
@@ -700,9 +715,9 @@ class UpgradeDependencies(Project, DryRun):
|
|
|
700
715
|
|
|
701
716
|
def gen(self: Self) -> str:
|
|
702
717
|
if self._tool == "uv":
|
|
703
|
-
return "uv lock --upgrade --verbose && uv sync --frozen"
|
|
718
|
+
return "uv lock --upgrade --verbose && uv sync --frozen --all-groups"
|
|
704
719
|
elif self._tool == "pdm":
|
|
705
|
-
return "pdm update --verbose && pdm
|
|
720
|
+
return "pdm update --verbose && pdm sync -G :all"
|
|
706
721
|
return self.gen_cmd() + " && poetry lock && poetry update"
|
|
707
722
|
|
|
708
723
|
|
|
@@ -741,6 +756,8 @@ class GitTag(DryRun):
|
|
|
741
756
|
cmd = f"git tag -a {_version} -m {self.message!r} && git push --tags"
|
|
742
757
|
if self.should_push():
|
|
743
758
|
cmd += " && git push"
|
|
759
|
+
if Project.is_pdm_project():
|
|
760
|
+
cmd = "pdm sync --prod && " + cmd
|
|
744
761
|
return cmd
|
|
745
762
|
|
|
746
763
|
@cached_property
|
|
@@ -42,7 +42,7 @@ dependencies = [
|
|
|
42
42
|
"bumpversion2 >=1.4.3,<2",
|
|
43
43
|
"pytest >=8.2.0,<9",
|
|
44
44
|
]
|
|
45
|
-
version = "0.16.
|
|
45
|
+
version = "0.16.2"
|
|
46
46
|
|
|
47
47
|
[project.urls]
|
|
48
48
|
Homepage = "https://github.com/waketzheng/fast-dev-cli"
|
|
@@ -55,6 +55,11 @@ include-optional-dependencies = [
|
|
|
55
55
|
[project.scripts]
|
|
56
56
|
fast = "fast_dev_cli:cli.main"
|
|
57
57
|
|
|
58
|
+
[dependency-groups]
|
|
59
|
+
dev = [
|
|
60
|
+
"twine>=6.1.0",
|
|
61
|
+
]
|
|
62
|
+
|
|
58
63
|
[tool.pdm]
|
|
59
64
|
distribution = true
|
|
60
65
|
|
|
@@ -72,6 +77,46 @@ dev = [
|
|
|
72
77
|
"-e file:///${PROJECT_ROOT}/#egg=fast-dev-cli[all]",
|
|
73
78
|
]
|
|
74
79
|
|
|
80
|
+
[tool.pdm.scripts]
|
|
81
|
+
test = "pdm run fast test"
|
|
82
|
+
check = "pdm run fast check {args}"
|
|
83
|
+
lint = "pdm run fast lint {args}"
|
|
84
|
+
deps = "pdm sync -G :all {args}"
|
|
85
|
+
prod = "pdm install --prod --frozen"
|
|
86
|
+
tree = "pdm list --tree"
|
|
87
|
+
update_self_version = "pdm sync"
|
|
88
|
+
|
|
89
|
+
[tool.pdm.scripts.style]
|
|
90
|
+
composite = [
|
|
91
|
+
"ruff format",
|
|
92
|
+
"ruff check --fix {args}",
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
[tool.pdm.scripts.bump]
|
|
96
|
+
composite = [
|
|
97
|
+
"update_self_version",
|
|
98
|
+
"pdm run fast bump patch --commit {args}",
|
|
99
|
+
]
|
|
100
|
+
|
|
101
|
+
[tool.pdm.scripts.tag]
|
|
102
|
+
composite = [
|
|
103
|
+
"update_self_version",
|
|
104
|
+
"pdm run fast tag {args}",
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
[tool.pdm.scripts.start]
|
|
108
|
+
composite = [
|
|
109
|
+
"pre-commit install",
|
|
110
|
+
"deps",
|
|
111
|
+
]
|
|
112
|
+
|
|
113
|
+
[tool.pdm.scripts.ci]
|
|
114
|
+
composite = [
|
|
115
|
+
"deps",
|
|
116
|
+
"check",
|
|
117
|
+
"test",
|
|
118
|
+
]
|
|
119
|
+
|
|
75
120
|
[tool.waketzheng._internal-slim-build.packages.fastdevcli-slim.project]
|
|
76
121
|
name = "fastdevcli-slim"
|
|
77
122
|
|
|
@@ -155,6 +200,7 @@ extend-select = [
|
|
|
155
200
|
]
|
|
156
201
|
"fast_dev_cli/cli.py" = [
|
|
157
202
|
"UP007",
|
|
203
|
+
"UP045",
|
|
158
204
|
]
|
|
159
205
|
|
|
160
206
|
[tool.bandit]
|
|
@@ -164,11 +210,3 @@ exclude_dirs = [
|
|
|
164
210
|
"examples",
|
|
165
211
|
".venv",
|
|
166
212
|
]
|
|
167
|
-
|
|
168
|
-
[dependency-groups]
|
|
169
|
-
ci = [
|
|
170
|
-
"coveralls @ git+https://github.com/waketzheng/coveralls-python@4.1.1",
|
|
171
|
-
]
|
|
172
|
-
dev = [
|
|
173
|
-
"twine>=6.1.0",
|
|
174
|
-
]
|
|
@@ -39,12 +39,14 @@ def test_enum():
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
def _bump_commands(
|
|
42
|
-
version: str, filename=TOML_FILE, emoji=False
|
|
42
|
+
version: str, filename=TOML_FILE, emoji=False, add_sync=True
|
|
43
43
|
) -> tuple[str, str, str]:
|
|
44
44
|
cmd = rf'bumpversion --parse "(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)" --current-version="{version}"'
|
|
45
45
|
suffix = " --commit && git push && git push --tags && git log -1"
|
|
46
46
|
if emoji:
|
|
47
47
|
suffix = suffix.replace("--commit", "--commit --message-emoji=1")
|
|
48
|
+
if add_sync:
|
|
49
|
+
cmd = "pdm sync --prod && " + cmd
|
|
48
50
|
patch_without_commit = cmd + f" patch {filename} --allow-dirty"
|
|
49
51
|
patch_with_commit = cmd + f" patch {filename}" + suffix
|
|
50
52
|
minor_with_commit = cmd + f" minor {filename} --tag" + suffix
|
|
@@ -99,7 +101,9 @@ def test_bump(
|
|
|
99
101
|
def test_bump_with_poetry(mocker, tmp_poetry_project, tmp_path):
|
|
100
102
|
mocker.patch("builtins.input", return_value=" ")
|
|
101
103
|
version = get_current_version()
|
|
102
|
-
patch_without_commit, patch_with_commit, minor_with_commit = _bump_commands(
|
|
104
|
+
patch_without_commit, patch_with_commit, minor_with_commit = _bump_commands(
|
|
105
|
+
version, add_sync=False
|
|
106
|
+
)
|
|
103
107
|
stream = StringIO()
|
|
104
108
|
with redirect_stdout(stream):
|
|
105
109
|
BumpUp(part="patch", commit=False).run()
|
|
@@ -167,7 +171,7 @@ def test_bump_with_emoji(mocker, tmp_path, monkeypatch):
|
|
|
167
171
|
def test_bump_with_emoji_in_poetry_project(mocker, tmp_path, monkeypatch):
|
|
168
172
|
# real bump
|
|
169
173
|
last_commit = "📝 Update release notes"
|
|
170
|
-
_, patch_with_commit, __ = _bump_commands("0.1.0", emoji=True)
|
|
174
|
+
_, patch_with_commit, __ = _bump_commands("0.1.0", emoji=True, add_sync=False)
|
|
171
175
|
with prepare_poetry_project(tmp_path):
|
|
172
176
|
subprocess.run(["git", "init"])
|
|
173
177
|
subprocess.run(["git", "add", "."])
|
|
@@ -365,3 +369,39 @@ build-backend = "pdm.backend"
|
|
|
365
369
|
out = capture_cmd_output("fast bump patch")
|
|
366
370
|
assert str(version_file) in out
|
|
367
371
|
assert "0.3.1" in version_file.read_text()
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
def test_installed_version_is_0_0_0(tmp_work_dir):
|
|
375
|
+
project_name = "my-project"
|
|
376
|
+
package_name = "app"
|
|
377
|
+
Path(project_name).mkdir()
|
|
378
|
+
with chdir(project_name):
|
|
379
|
+
Path(package_name).mkdir()
|
|
380
|
+
version_file = Path(package_name, "__init__.py")
|
|
381
|
+
version_file.write_text('__version__ = "0.3.0"')
|
|
382
|
+
toml_file = Path("pyproject.toml")
|
|
383
|
+
toml_file.write_text("""
|
|
384
|
+
[project]
|
|
385
|
+
name = "my-project"
|
|
386
|
+
description = ""
|
|
387
|
+
authors = [{name="Waket Zheng", email="waketzheng@gmail.com"}]
|
|
388
|
+
readme = "README.md"
|
|
389
|
+
dynamic = ["version"]
|
|
390
|
+
keywords = []
|
|
391
|
+
requires-python = ">=3.9"
|
|
392
|
+
dependencies = []
|
|
393
|
+
|
|
394
|
+
[tool.pdm]
|
|
395
|
+
distribution = false
|
|
396
|
+
|
|
397
|
+
[tool.pdm.version]
|
|
398
|
+
source = "file"
|
|
399
|
+
path = "app/__init__.py"
|
|
400
|
+
|
|
401
|
+
[build-system]
|
|
402
|
+
requires = ["pdm-backend"]
|
|
403
|
+
build-backend = "pdm.backend"
|
|
404
|
+
""")
|
|
405
|
+
out = capture_cmd_output("fast bump patch")
|
|
406
|
+
assert str(version_file) in out
|
|
407
|
+
assert "0.3.1" in version_file.read_text()
|
|
@@ -52,12 +52,14 @@ def test_with_push(mocker):
|
|
|
52
52
|
mocker.patch.object(git_tag, "git_status", return_value="git push")
|
|
53
53
|
version = get_current_version()
|
|
54
54
|
prefix = "v" if "v" in capture_cmd_output(["git", "tag"]) else ""
|
|
55
|
-
|
|
55
|
+
sync = "pdm sync --prod"
|
|
56
|
+
push = "git push --tags"
|
|
57
|
+
assert git_tag.gen() == f"{sync} && git tag -a {prefix}{version} -m '' && {push}"
|
|
56
58
|
with _clear_tags():
|
|
57
59
|
git_tag_cmd = git_tag.gen()
|
|
58
|
-
assert git_tag_cmd == f"git tag -a {version} -m '' &&
|
|
60
|
+
assert git_tag_cmd == f"{sync} && git tag -a {version} -m '' && {push}"
|
|
59
61
|
mocker.patch.object(git_tag, "has_v_prefix", return_value=True)
|
|
60
|
-
tag_cmd = f"git tag -a v{version} -m '' &&
|
|
62
|
+
tag_cmd = f"{sync} && git tag -a v{version} -m '' && {push}"
|
|
61
63
|
assert git_tag.gen() == tag_cmd
|
|
62
64
|
mocker.patch.object(git_tag, "should_push", return_value=True)
|
|
63
65
|
assert git_tag.gen() == tag_cmd + " && git push"
|
|
@@ -292,7 +292,7 @@ fastapi = "^0.112.2"
|
|
|
292
292
|
|
|
293
293
|
def test_upgrade_uv_project():
|
|
294
294
|
cmd = "fast upgrade --tool=uv --dry"
|
|
295
|
-
expected = "uv lock --upgrade --verbose && uv sync --frozen"
|
|
295
|
+
expected = "uv lock --upgrade --verbose && uv sync --frozen --all-groups"
|
|
296
296
|
assert expected in capture_cmd_output(cmd)
|
|
297
297
|
assert expected in capture_cmd_output("pdm run " + cmd)
|
|
298
298
|
assert UpgradeDependencies(tool="uv").gen() == expected
|
|
@@ -300,7 +300,7 @@ def test_upgrade_uv_project():
|
|
|
300
300
|
|
|
301
301
|
def test_upgrade_pdm_project():
|
|
302
302
|
cmd = "fast upgrade --tool=pdm --dry"
|
|
303
|
-
expected = "pdm update --verbose && pdm
|
|
303
|
+
expected = "pdm update --verbose && pdm sync -G :all"
|
|
304
304
|
assert expected in capture_cmd_output(cmd)
|
|
305
305
|
assert expected in capture_cmd_output("pdm run " + cmd)
|
|
306
306
|
assert UpgradeDependencies(tool="pdm").gen() == expected
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.16.0"
|
|
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
|