fast-dev-cli 0.15.1__tar.gz → 0.15.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.15.1 → fast_dev_cli-0.15.2}/PKG-INFO +1 -1
- fast_dev_cli-0.15.2/fast_dev_cli/__init__.py +1 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/fast_dev_cli/cli.py +40 -16
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/pyproject.toml +4 -4
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/tests/test_bump.py +73 -1
- fast_dev_cli-0.15.1/fast_dev_cli/__init__.py +0 -1
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/LICENSE +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/README.md +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/fast_dev_cli/__main__.py +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/fast_dev_cli/py.typed +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/pdm_build.py +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/scripts/check.py +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/scripts/format.py +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/scripts/test.py +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/tests/__init__.py +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/tests/conftest.py +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/tests/test_fast_test.py +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/tests/test_functions.py +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/tests/test_lint.py +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/tests/test_poetry_version_plugin.py +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/tests/test_runserver.py +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/tests/test_sync.py +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/tests/test_tag.py +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/tests/test_upgrade.py +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/tests/test_upload.py +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/tests/test_version.py +0 -0
- {fast_dev_cli-0.15.1 → fast_dev_cli-0.15.2}/tests/utils.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.15.2"
|
|
@@ -122,16 +122,27 @@ def _parse_version(line: str, pattern: re.Pattern[str]) -> str:
|
|
|
122
122
|
def read_version_from_file(
|
|
123
123
|
package_name: str, work_dir: Path | None = None, toml_text: str | None = None
|
|
124
124
|
) -> str:
|
|
125
|
-
if
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
125
|
+
if not package_name and toml_text:
|
|
126
|
+
pattern = re.compile(r"version\s*=")
|
|
127
|
+
for line in toml_text.splitlines():
|
|
128
|
+
if pattern.match(line):
|
|
129
|
+
return _parse_version(line, pattern)
|
|
130
|
+
version_file = BumpUp.parse_filename(toml_text, work_dir, package_name)
|
|
131
|
+
if version_file == TOML_FILE:
|
|
132
|
+
if toml_text is None:
|
|
133
|
+
toml_text = Project.load_toml_text()
|
|
134
|
+
context = tomllib.loads(toml_text)
|
|
135
|
+
with contextlib.suppress(KeyError):
|
|
136
|
+
return context["project"]["version"]
|
|
137
|
+
with contextlib.suppress(KeyError): # Poetry V1
|
|
138
|
+
return context["tool"]["poetry"]["version"]
|
|
139
|
+
secho(f"WARNING: can not find 'version' item in {version_file}!")
|
|
140
|
+
return "0.0.0"
|
|
141
|
+
pattern = re.compile(r"__version__\s*=")
|
|
142
|
+
for line in Path(version_file).read_text("utf-8").splitlines():
|
|
130
143
|
if pattern.match(line):
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
break
|
|
134
|
-
return lib_version
|
|
144
|
+
return _parse_version(line, pattern)
|
|
145
|
+
# TODO: remove or refactor the following lines.
|
|
135
146
|
if work_dir is None:
|
|
136
147
|
work_dir = Project.get_work_dir()
|
|
137
148
|
package_dir = work_dir / package_name
|
|
@@ -142,6 +153,7 @@ def read_version_from_file(
|
|
|
142
153
|
):
|
|
143
154
|
secho("WARNING: __init__.py file does not exist!")
|
|
144
155
|
return "0.0.0"
|
|
156
|
+
|
|
145
157
|
pattern = re.compile(r"__version__\s*=")
|
|
146
158
|
for line in init_file.read_text("utf-8").splitlines():
|
|
147
159
|
if pattern.match(line):
|
|
@@ -258,8 +270,13 @@ class BumpUp(DryRun):
|
|
|
258
270
|
return emoji.is_emoji(first_char)
|
|
259
271
|
|
|
260
272
|
@staticmethod
|
|
261
|
-
def parse_filename(
|
|
262
|
-
toml_text =
|
|
273
|
+
def parse_filename(
|
|
274
|
+
toml_text: str | None = None,
|
|
275
|
+
work_dir: Path | None = None,
|
|
276
|
+
package_name: str | None = None,
|
|
277
|
+
) -> str:
|
|
278
|
+
if toml_text is None:
|
|
279
|
+
toml_text = Project.load_toml_text()
|
|
263
280
|
context = tomllib.loads(toml_text)
|
|
264
281
|
by_version_plugin = False
|
|
265
282
|
try:
|
|
@@ -277,14 +294,14 @@ class BumpUp(DryRun):
|
|
|
277
294
|
version_value = context["tool"]["poetry"]["version"]
|
|
278
295
|
except KeyError:
|
|
279
296
|
if not Project.manage_by_poetry():
|
|
297
|
+
if work_dir is None:
|
|
298
|
+
work_dir = Project.get_work_dir()
|
|
280
299
|
for tool in ("pdm", "hatch"):
|
|
281
300
|
with contextlib.suppress(KeyError):
|
|
282
301
|
version_path = context["tool"][tool]["version"]["path"]
|
|
283
302
|
if (
|
|
284
303
|
Path(version_path).exists()
|
|
285
|
-
or
|
|
286
|
-
.joinpath(version_path)
|
|
287
|
-
.exists()
|
|
304
|
+
or work_dir.joinpath(version_path).exists()
|
|
288
305
|
):
|
|
289
306
|
return version_path
|
|
290
307
|
# version = { source = "file", path = "fast_dev_cli/__init__.py" }
|
|
@@ -295,7 +312,7 @@ class BumpUp(DryRun):
|
|
|
295
312
|
continue
|
|
296
313
|
if p_key in (value := line.split(v_key, 1)[-1].split("#")[0]):
|
|
297
314
|
filename = value.split(p_key, 1)[-1].split('"')[0]
|
|
298
|
-
if
|
|
315
|
+
if work_dir.joinpath(filename).exists():
|
|
299
316
|
return filename
|
|
300
317
|
else:
|
|
301
318
|
by_version_plugin = version_value in ("0", "0.0.0", "init")
|
|
@@ -319,6 +336,8 @@ class BumpUp(DryRun):
|
|
|
319
336
|
cwd = Path.cwd()
|
|
320
337
|
pattern = re.compile(r"__version__\s*=\s*['\"]")
|
|
321
338
|
ds: list[Path] = []
|
|
339
|
+
if package_name is not None:
|
|
340
|
+
packages.insert(0, (package_name, ""))
|
|
322
341
|
for package_name, source_dir in packages:
|
|
323
342
|
ds.append(cwd / package_name)
|
|
324
343
|
ds.append(cwd / "src" / package_name)
|
|
@@ -328,7 +347,12 @@ class BumpUp(DryRun):
|
|
|
328
347
|
ds.extend([cwd / module_name, cwd / "src" / module_name, cwd])
|
|
329
348
|
for d in ds:
|
|
330
349
|
init_file = d / "__init__.py"
|
|
331
|
-
if
|
|
350
|
+
if (
|
|
351
|
+
init_file.exists() and pattern.search(init_file.read_text("utf8"))
|
|
352
|
+
) or (
|
|
353
|
+
(init_file := init_file.with_name("__version__.py")).exists()
|
|
354
|
+
and pattern.search(init_file.read_text("utf8"))
|
|
355
|
+
):
|
|
332
356
|
break
|
|
333
357
|
else:
|
|
334
358
|
raise ParseError("Version file not found! Where are you now?")
|
|
@@ -32,16 +32,16 @@ classifiers = [
|
|
|
32
32
|
"License :: OSI Approved :: MIT License",
|
|
33
33
|
]
|
|
34
34
|
dependencies = [
|
|
35
|
-
"typer>=0.12.3,<1",
|
|
35
|
+
"typer >=0.12.3,<1",
|
|
36
36
|
"emoji >=2.12.1,<3",
|
|
37
|
-
"packaging>=20.5",
|
|
38
|
-
"tomli>=2.0.1,<3; python_version < '3.11'",
|
|
37
|
+
"packaging >=20.5",
|
|
38
|
+
"tomli >=2.0.1,<3; python_version < '3.11'",
|
|
39
39
|
"coverage >=7.5.1,<8",
|
|
40
40
|
"mypy >=1.15.0,<2",
|
|
41
41
|
"bumpversion2 >=1.4.3,<2",
|
|
42
42
|
"pytest >=8.2.0,<9",
|
|
43
43
|
]
|
|
44
|
-
version = "0.15.
|
|
44
|
+
version = "0.15.2"
|
|
45
45
|
|
|
46
46
|
[project.urls]
|
|
47
47
|
Homepage = "https://github.com/waketzheng/fast-dev-cli"
|
|
@@ -288,8 +288,80 @@ dynamic = ["readme", "version"]
|
|
|
288
288
|
path = "httpx/__version__.py"
|
|
289
289
|
""")
|
|
290
290
|
Path(project_name).mkdir()
|
|
291
|
-
Path("httpx/__version__.py")
|
|
291
|
+
version_file = Path("httpx/__version__.py")
|
|
292
|
+
version_file.write_text("""
|
|
292
293
|
__title__ = "httpx"
|
|
293
294
|
__description__ = "A next generation HTTP client, for Python 3."
|
|
294
295
|
__version__ = "0.28.1"
|
|
295
296
|
""")
|
|
297
|
+
out = capture_cmd_output("fast bump patch")
|
|
298
|
+
assert str(version_file) in out
|
|
299
|
+
assert "0.28.2" in version_file.read_text()
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
def test_package_project_diff(tmp_work_dir):
|
|
303
|
+
project_name = "tortoise-database-url"
|
|
304
|
+
package_name = "database_url"
|
|
305
|
+
Path(project_name).mkdir()
|
|
306
|
+
with chdir(project_name):
|
|
307
|
+
Path(package_name).mkdir()
|
|
308
|
+
version_file = Path(package_name, "__init__.py")
|
|
309
|
+
version_file.write_text('__version__ = "0.3.0"')
|
|
310
|
+
toml_file = Path("pyproject.toml")
|
|
311
|
+
toml_file.write_text("""
|
|
312
|
+
[project]
|
|
313
|
+
name = "tortoise-database-url"
|
|
314
|
+
description = "Make it easy to generate database url."
|
|
315
|
+
authors = [{name="Waket Zheng", email="waketzheng@gmail.com"}]
|
|
316
|
+
readme = "README.md"
|
|
317
|
+
dynamic = ["version"]
|
|
318
|
+
keywords = ["database_url", "tortoise-orm"]
|
|
319
|
+
requires-python = ">=3.9"
|
|
320
|
+
dependencies = []
|
|
321
|
+
|
|
322
|
+
[tool.pdm.version]
|
|
323
|
+
source = "file"
|
|
324
|
+
path = "database_url/__init__.py"
|
|
325
|
+
|
|
326
|
+
[build-system]
|
|
327
|
+
requires = ["pdm-backend"]
|
|
328
|
+
build-backend = "pdm.backend"
|
|
329
|
+
""")
|
|
330
|
+
out = capture_cmd_output("fast bump patch")
|
|
331
|
+
assert str(version_file) in out
|
|
332
|
+
assert "0.3.1" in version_file.read_text()
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def test_version_file_in_work_dir(tmp_work_dir):
|
|
336
|
+
project_name = package_name = "bigmodels"
|
|
337
|
+
Path(project_name).mkdir()
|
|
338
|
+
with chdir(project_name):
|
|
339
|
+
Path(package_name).mkdir()
|
|
340
|
+
version_file = Path("__version__.py")
|
|
341
|
+
version_file.write_text('__version__ = "0.3.0"')
|
|
342
|
+
toml_file = Path("pyproject.toml")
|
|
343
|
+
toml_file.write_text("""
|
|
344
|
+
[project]
|
|
345
|
+
name = "bigmodels"
|
|
346
|
+
description = ""
|
|
347
|
+
authors = [{name="Waket Zheng", email="waketzheng@gmail.com"}]
|
|
348
|
+
readme = "README.md"
|
|
349
|
+
dynamic = ["version"]
|
|
350
|
+
keywords = []
|
|
351
|
+
requires-python = ">=3.9"
|
|
352
|
+
dependencies = []
|
|
353
|
+
|
|
354
|
+
[tool.pdm]
|
|
355
|
+
distribution = false
|
|
356
|
+
|
|
357
|
+
[tool.pdm.version]
|
|
358
|
+
source = "file"
|
|
359
|
+
path = "__version__.py"
|
|
360
|
+
|
|
361
|
+
[build-system]
|
|
362
|
+
requires = ["pdm-backend"]
|
|
363
|
+
build-backend = "pdm.backend"
|
|
364
|
+
""")
|
|
365
|
+
out = capture_cmd_output("fast bump patch")
|
|
366
|
+
assert str(version_file) in out
|
|
367
|
+
assert "0.3.1" in version_file.read_text()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.15.1"
|
|
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
|