Skip to content

Commit 7647995

Browse files
authored
Merge pull request #4 from TimChild/update-for-clerk-backend-2
Update for clerk backend 2
2 parents 67374c2 + aaaf35a commit 7647995

File tree

9 files changed

+59
-67
lines changed

9 files changed

+59
-67
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![Test Status](https://github.com/TimChild/reflex-clerk-api/actions/workflows/ci.yml/badge.svg?branch=v0.3.0)
1+
![Test Status](https://github.com/TimChild/reflex-clerk-api/actions/workflows/ci.yml/badge.svg?branch=v0.3.1)
22
![PyPi publish Status](https://github.com/TimChild/reflex-clerk-api/actions/workflows/publish.yml/badge.svg)
33
![Demo Deploy Status](https://github.com/TimChild/reflex-clerk-api/actions/workflows/deploy.yml/badge.svg)
44

Taskfile.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ version: "3"
22

33
dotenv: [".env"]
44

5+
vars:
6+
INIT_PATH: "custom_components/reflex_clerk_api/__init__.py"
7+
58
tasks:
69
install:
710
cmds:
@@ -23,6 +26,7 @@ tasks:
2326
- task: lint
2427
- task: typecheck
2528
cmds:
29+
- uv sync --dev
2630
- uv run playwright install chromium
2731
- uv run pytest
2832

@@ -37,19 +41,19 @@ tasks:
3741
bump-patch:
3842
dir: "{{.TASKFILE_DIR}}"
3943
cmds:
40-
- uv run scripts/bump-version.py patch pyproject.toml README.md
44+
- uv run scripts/bump-version.py patch {{.INIT_PATH}} README.md
4145
- uv lock
4246

4347
bump-minor:
4448
dir: "{{.TASKFILE_DIR}}"
4549
cmds:
46-
- uv run scripts/bump-version.py minor pyproject.toml README.md
50+
- uv run scripts/bump-version.py minor {{.INIT_PATH}} README.md
4751
- uv lock
4852

4953
bump-major:
5054
dir: "{{.TASKFILE_DIR}}"
5155
cmds:
52-
- uv run scripts/bump-version.py major pyproject.toml README.md
56+
- uv run scripts/bump-version.py major {{.INIT_PATH}} README.md
5357
- uv lock
5458

5559
publish:

clerk_api_demo/clerk_api_demo/clerk_api_demo.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ async def do_something_on_log_in_or_out(self) -> EventType | None:
7575

7676
def demo_page_header_and_description() -> rx.Component:
7777
return rx.vstack(
78-
rx.heading("reflex-clerk-api demo", size="9"),
78+
rx.hstack(
79+
rx.heading("reflex-clerk-api demo", size="9"),
80+
rx.text(clerk.__version__),
81+
align="baseline",
82+
),
7983
rx.heading(
8084
"Custom",
8185
rx.link(rx.code("reflex"), href="https://reflex.dev"),

custom_components/reflex_clerk_api/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
__version__ = "0.3.1"
2+
13
from .authentication_components import sign_in, sign_up
24
from .clerk_provider import (
35
ClerkState,

custom_components/reflex_clerk_api/clerk_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ async def _get_jwk_keys(self) -> dict[str, Any]:
210210
"""
211211
if self._jwk_keys:
212212
return self._jwk_keys
213-
jwks = await self.client.jwks.get_async()
213+
jwks = await self.client.jwks.get_jwks_async()
214214
assert jwks is not None
215215
assert jwks.keys is not None
216216
keys = jwks.model_dump()["keys"]

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "reflex-clerk-api"
7-
version = "0.3.0"
87
description = "Reflex custom component wrapping @clerk/clerk-react and integrating the clerk-backend-api"
98
readme = "README.md"
109
license = { text = "Apache-2.0" }
1110
requires-python = ">=3.10"
1211
authors = [{ name = "Tim Child", email = "[email protected]" }]
1312
keywords = ["reflex","reflex-custom-components", "clerk", "clerk-backend-api"]
13+
dynamic = ["version"]
1414

1515
dependencies = [
1616
"authlib>=1.5.1,<2.0.0",
17-
"clerk-backend-api>=1.8.0,<2.0.0",
17+
"clerk-backend-api>=2.0.0,<3.0.0",
1818
"reflex>=0.7.2,<0.8.0",
1919
]
2020

@@ -41,6 +41,9 @@ dev = ["build", "twine"]
4141
[tool.setuptools.packages.find]
4242
where = ["custom_components"]
4343

44+
[tool.setuptools.dynamic]
45+
version = {attr = "reflex_clerk_api.__version__"}
46+
4447
[tool.pytest.ini_options]
4548
# addopts = "--headed"
4649

scripts/bump-version.py

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1+
import re
12
import sys
23
from pathlib import Path
34
from typing import Literal
45

56
import semver
6-
import tomlkit
77

88
LITERAL_PART = Literal["major", "minor", "patch"]
99

1010

11-
def get_version_from_pyproject_toml(file_path: Path) -> str:
12-
with file_path.open("r") as file:
13-
data = tomlkit.parse(file.read())
14-
version = data["project"]["version"] # pyright: ignore[reportIndexIssue]
15-
assert isinstance(version, str)
16-
return version
11+
def get_version_from_init(init_path: Path) -> str:
12+
with init_path.open("r") as file:
13+
data = file.readline()
14+
match = re.search(r'^__version__ = "(.*)"', data)
15+
assert match is not None
16+
return match.group(1)
1717

1818

1919
def bump_version(version: str, part: LITERAL_PART) -> str:
@@ -26,12 +26,15 @@ def bump_version(version: str, part: LITERAL_PART) -> str:
2626
return semver.bump_patch(version)
2727

2828

29-
def update_toml_project_version(file_path: Path, new_version: str) -> None:
30-
with file_path.open("r") as file:
31-
data = tomlkit.parse(file.read())
32-
data["project"]["version"] = new_version # pyright: ignore[reportIndexIssue]
33-
with file_path.open("w") as file:
34-
file.write(tomlkit.dumps(data))
29+
def update_init_version(init_path: Path, new_version: str) -> None:
30+
with init_path.open("r") as file:
31+
lines = file.readlines()
32+
33+
# Update the first line with the new version
34+
lines[0] = f'__version__ = "{new_version}"\n'
35+
36+
with init_path.open("w") as file:
37+
file.writelines(lines)
3538

3639

3740
def update_readme_badge(readme_path: Path, new_version: str) -> None:
@@ -48,23 +51,23 @@ def update_readme_badge(readme_path: Path, new_version: str) -> None:
4851
file.writelines(lines)
4952

5053

51-
def main(part: LITERAL_PART, pyproject_path: Path, readme_path: Path) -> None:
52-
current_version = get_version_from_pyproject_toml(pyproject_path)
54+
def main(part: LITERAL_PART, init_path: Path, readme_path: Path) -> None:
55+
current_version = get_version_from_init(init_path)
5356
new_version = bump_version(current_version, part)
54-
update_toml_project_version(pyproject_path, new_version)
57+
update_init_version(init_path, new_version)
5558
update_readme_badge(readme_path, new_version)
5659
print(f"Successfully bumped from {current_version} to {new_version}") # noqa: T201
5760

5861

5962
if __name__ == "__main__":
6063
if len(sys.argv) != 4:
6164
raise ValueError(
62-
"Usage: bump-version.py <major|minor|patch> <pyproject.toml-path> <readme-path>"
65+
"Usage: bump-version.py <major|minor|patch> <package.__init__.py-path> <readme-path>"
6366
)
6467
part = sys.argv[1]
6568
assert part in ("major", "minor", "patch")
66-
pyproject_path = Path(sys.argv[2])
67-
assert pyproject_path.exists()
69+
init_path = Path(sys.argv[2])
70+
assert init_path.exists()
6871
readme_path = Path(sys.argv[3])
6972
assert readme_path.exists()
70-
main(part, pyproject_path, readme_path)
73+
main(part, init_path, readme_path)

scripts/get-version.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
"""Reads the version from the pyproject.toml file and returns to stdout."""
1+
"""Reads the version from the __init__.py file and returns to stdout."""
22

3+
import re
34
import sys
45
from pathlib import Path
56

6-
import tomlkit
77

8-
9-
def get_version_from_pyproject_toml(file_path: Path) -> str:
10-
with file_path.open("r") as file:
11-
data = tomlkit.parse(file.read())
12-
version = data["project"]["version"] # pyright: ignore[reportIndexIssue]
13-
assert isinstance(version, str)
14-
return version
8+
def get_version_from_init(init_path: Path) -> str:
9+
with init_path.open("r") as file:
10+
data = file.readline()
11+
match = re.search(r'^__version__ = "(.*)"', data)
12+
assert match is not None
13+
return match.group(1)
1514

1615

1716
if __name__ == "__main__":
1817
args = sys.argv
1918
if len(args) != 2:
20-
raise ValueError("Usage: get-version.py <pyproject.toml-path>")
19+
raise ValueError("Usage: get-version.py <package.__init__.py")
2120
path = Path(args[1])
2221
assert path.exists()
23-
print(get_version_from_pyproject_toml(path)) # noqa: T201
22+
print(get_version_from_init(path)) # noqa: T201

uv.lock

Lines changed: 5 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)