sweatstack-cli 0.17.0__tar.gz → 0.17.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 (100) hide show
  1. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/CHANGELOG.md +11 -0
  2. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/PKG-INFO +1 -1
  3. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/pyproject.toml +1 -1
  4. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/auth/tokens.py +16 -7
  5. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/commands/auth.py +15 -6
  6. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_auth/test_tokens.py +10 -3
  7. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_commands/test_auth.py +30 -0
  8. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/uv.lock +1 -1
  9. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/.claude/settings.local.json +0 -0
  10. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/.claude/skills/sweatstack/SKILL.md +0 -0
  11. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/.claude/skills/sweatstack/api.md +0 -0
  12. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/.claude/skills/sweatstack/auth.md +0 -0
  13. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/.claude/skills/sweatstack/cli.md +0 -0
  14. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/.claude/skills/sweatstack/pyscript.md +0 -0
  15. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/.claude/skills/sweatstack/webapp.md +0 -0
  16. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/.gitignore +0 -0
  17. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/.python-version +0 -0
  18. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/CREATE_PRIVATE_APP.md +0 -0
  19. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/DEVELOPMENT.md +0 -0
  20. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/Makefile +0 -0
  21. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/PLAN.md +0 -0
  22. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/README.md +0 -0
  23. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/plans/001-page-init-command.md +0 -0
  24. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/scripts/vendor_tool_template.sh +0 -0
  25. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/__init__.py +0 -0
  26. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/api/__init__.py +0 -0
  27. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/api/client.py +0 -0
  28. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/auth/__init__.py +0 -0
  29. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/auth/callback_server.py +0 -0
  30. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/auth/jwt.py +0 -0
  31. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/auth/pkce.py +0 -0
  32. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/commands/__init__.py +0 -0
  33. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/commands/app.py +0 -0
  34. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/commands/page.py +0 -0
  35. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/commands/tool.py +0 -0
  36. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/config.py +0 -0
  37. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/console.py +0 -0
  38. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/exceptions.py +0 -0
  39. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/go_live.py +0 -0
  40. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/main.py +0 -0
  41. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/project.py +0 -0
  42. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/py.typed +0 -0
  43. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/services/__init__.py +0 -0
  44. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/services/applications.py +0 -0
  45. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/templates/page/index.html +0 -0
  46. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/templates/tool/index.html +0 -0
  47. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/templates/tool/vendor/duckdb.mjs +0 -0
  48. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/templates/tool/vendor/licenses/apache-arrow.txt +0 -0
  49. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/templates/tool/vendor/licenses/duckdb-wasm.txt +0 -0
  50. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/templates/tool/vendor/licenses/uplot.txt +0 -0
  51. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/templates/tool/vendor/sweatstack.js +0 -0
  52. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/templates/tool/vendor/uPlot.iife.min-1.6.31.js +0 -0
  53. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/templates/tool/vendor/uPlot.min-1.6.31.css +0 -0
  54. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/templates/tool/vendor.json +0 -0
  55. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/tools/__init__.py +0 -0
  56. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/tools/check.py +0 -0
  57. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/tools/content_types.json +0 -0
  58. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/tools/deploy.py +0 -0
  59. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/tools/policy.json +0 -0
  60. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/tools/policy.py +0 -0
  61. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/tools/rewrite.py +0 -0
  62. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/tools/server.py +0 -0
  63. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/tools/signin.py +0 -0
  64. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/tools/template.py +0 -0
  65. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/src/sweatstack_cli/version_check.py +0 -0
  66. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/sweatstack.toml +0 -0
  67. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/__init__.py +0 -0
  68. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/conftest.py +0 -0
  69. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/e2e/__init__.py +0 -0
  70. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/e2e/fake_sweatstack.py +0 -0
  71. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/e2e/test_page_template.py +0 -0
  72. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/e2e/test_tool_serve.py +0 -0
  73. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/e2e/test_tool_template.py +0 -0
  74. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_api/__init__.py +0 -0
  75. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_api/test_client.py +0 -0
  76. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_auth/__init__.py +0 -0
  77. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_auth/test_authenticator.py +0 -0
  78. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_auth/test_authorize_url.py +0 -0
  79. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_auth/test_callback_server.py +0 -0
  80. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_auth/test_jwt.py +0 -0
  81. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_auth/test_pkce.py +0 -0
  82. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_commands/__init__.py +0 -0
  83. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_commands/test_app.py +0 -0
  84. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_commands/test_cli.py +0 -0
  85. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_commands/test_page_deploy.py +0 -0
  86. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_commands/test_page_init.py +0 -0
  87. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_commands/test_tool_commands.py +0 -0
  88. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_project.py +0 -0
  89. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_services/__init__.py +0 -0
  90. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_services/test_applications.py +0 -0
  91. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_tools/__init__.py +0 -0
  92. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_tools/test_check.py +0 -0
  93. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_tools/test_deploy.py +0 -0
  94. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_tools/test_policy.py +0 -0
  95. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_tools/test_rewrite.py +0 -0
  96. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_tools/test_server.py +0 -0
  97. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_tools/test_signin.py +0 -0
  98. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_tools/test_template.py +0 -0
  99. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_version.py +0 -0
  100. {sweatstack_cli-0.17.0 → sweatstack_cli-0.17.1}/tests/test_version_check.py +0 -0
@@ -4,6 +4,17 @@ All notable changes to this project are documented here. The format is based on
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
5
5
  adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.17.1] - 2026-11-20
8
+
9
+ ### Fixed
10
+
11
+ - Signing in to another SweatStack with `SWEATSTACK_URL`, such as staging, no longer
12
+ replaces the production sign-in. Production keeps `tokens.json`, shared with the
13
+ Python library, and any other SweatStack its own `tokens-{host}.json`. If you signed in
14
+ to another SweatStack with an earlier version, run `sweatstack login` again.
15
+ - `sweatstack status` says "Not authenticated", and exits with 1, when SweatStack refuses
16
+ the stored sign-in, instead of "Authenticated" without a name.
17
+
7
18
  ## [0.17.0] - 2026-11-20
8
19
 
9
20
  ### Added
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: sweatstack-cli
3
- Version: 0.17.0
3
+ Version: 0.17.1
4
4
  Summary: Command-line interface for SweatStack — the sports data platform for developers
5
5
  Project-URL: Homepage, https://sweatstack.no
6
6
  Project-URL: Documentation, https://docs.sweatstack.no
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sweatstack-cli"
3
- version = "0.17.0"
3
+ version = "0.17.1"
4
4
  description = "Command-line interface for SweatStack — the sports data platform for developers"
5
5
  readme = "README.md"
6
6
  authors = [{ name = "Aart Goossens", email = "aart@sweatstack.no" }]
@@ -4,24 +4,29 @@ from __future__ import annotations
4
4
 
5
5
  import json
6
6
  import os
7
+ import re
7
8
  import time
8
9
  from dataclasses import dataclass
9
10
  from pathlib import Path
10
11
  from typing import Protocol
12
+ from urllib.parse import urlsplit
11
13
 
12
14
  import platformdirs
13
15
 
16
+ from sweatstack_cli.config import DEFAULT_API_URL, get_settings
14
17
 
15
- def get_tokens_path() -> Path:
18
+
19
+ def get_tokens_path(api_url: str | None = None) -> Path:
16
20
  """
17
- Get the path to the tokens file.
21
+ Get the path to the tokens file of the SweatStack at `api_url` (`SWEATSTACK_URL`'s by default).
18
22
 
19
- Uses platformdirs for OS-appropriate user data directory.
20
- This path is shared with the sweatstack Python library for
21
- seamless interoperability.
23
+ Uses platformdirs for OS-appropriate user data directory. Production's sign-in is
24
+ `tokens.json`, shared with the sweatstack Python library for seamless interoperability.
25
+ Any other SweatStack, such as staging, keeps its own file named after its host, so
26
+ signing in there never replaces the production sign-in.
22
27
 
23
28
  Returns:
24
- Path to tokens.json file.
29
+ Path to tokens.json, or tokens-{host}.json for another SweatStack.
25
30
 
26
31
  Platform-specific paths:
27
32
  - macOS: ~/Library/Application Support/SweatStack/tokens.json
@@ -29,7 +34,11 @@ def get_tokens_path() -> Path:
29
34
  - Windows: %APPDATA%\\SweatStack\\SweatStack\\tokens.json
30
35
  """
31
36
  data_dir = Path(platformdirs.user_data_dir("SweatStack", "SweatStack"))
32
- return data_dir / "tokens.json"
37
+ url = (api_url or get_settings().api_url).rstrip("/")
38
+ if url == DEFAULT_API_URL:
39
+ return data_dir / "tokens.json"
40
+ host = re.sub(r"[^A-Za-z0-9.-]", "-", urlsplit(url).netloc or url)
41
+ return data_dir / f"tokens-{host}.json"
33
42
 
34
43
 
35
44
  @dataclass(frozen=True, slots=True)
@@ -3,6 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  from datetime import datetime
6
+ from typing import Any
6
7
 
7
8
  import typer
8
9
 
@@ -10,7 +11,7 @@ from sweatstack_cli.api import APIClient
10
11
  from sweatstack_cli.auth import Authenticator
11
12
  from sweatstack_cli.auth.jwt import decode_jwt_payload
12
13
  from sweatstack_cli.console import console
13
- from sweatstack_cli.exceptions import APIError, AuthenticationError
14
+ from sweatstack_cli.exceptions import APIError, AuthenticationError, SecondFactorRequired
14
15
  from sweatstack_cli.version_check import check_for_update
15
16
 
16
17
 
@@ -92,18 +93,26 @@ def status() -> None:
92
93
  auth = Authenticator()
93
94
  tokens = auth.get_valid_tokens()
94
95
 
96
+ user: dict[str, Any] | None = None
97
+ if tokens is not None:
98
+ try:
99
+ user = APIClient(authenticator=auth).get("/api/v1/oauth/userinfo")
100
+ except SecondFactorRequired:
101
+ pass # A step-up is not a refusal of the sign-in.
102
+ except AuthenticationError:
103
+ # Stored tokens SweatStack refuses (revoked, or from another SweatStack) are no sign-in.
104
+ tokens = None
105
+ except APIError:
106
+ pass # SweatStack could not say who this is; the sign-in may still be good.
107
+
95
108
  if tokens is None:
96
109
  console.print("[red]✗[/red] Not authenticated")
97
110
  else:
98
111
  console.print("[green]✓[/green] Authenticated")
99
- try:
100
- client = APIClient(authenticator=auth)
101
- user = client.get("/api/v1/oauth/userinfo")
112
+ if user is not None:
102
113
  console.print(f" Name: {_display_name(user)}")
103
114
  console.print(f" Email: {user.get('email', 'unknown')}")
104
115
  console.print(f" ID: {user.get('sub', 'unknown')}")
105
- except (AuthenticationError, APIError):
106
- pass # Silently skip user info on error
107
116
  console.print(f" Passkey: {_confirmation(tokens.access_token)}")
108
117
 
109
118
  # Check version
@@ -163,9 +163,16 @@ class TestGetTokensPath:
163
163
  assert isinstance(result, Path)
164
164
 
165
165
  def test_ends_with_tokens_json(self) -> None:
166
- """Should point to tokens.json."""
167
- result = get_tokens_path()
168
- assert result.name == "tokens.json"
166
+ """Production's sign-in is tokens.json, shared with the Python library."""
167
+ assert get_tokens_path("https://app.sweatstack.no").name == "tokens.json"
168
+ assert get_tokens_path("https://app.sweatstack.no/").name == "tokens.json"
169
+
170
+ def test_another_sweatstack_keeps_its_own_file(self) -> None:
171
+ """Signing in to staging never replaces the production sign-in."""
172
+ staging = get_tokens_path("https://staging.sweatstack.no")
173
+ assert staging.name == "tokens-staging.sweatstack.no.json"
174
+ assert staging.parent == get_tokens_path("https://app.sweatstack.no").parent
175
+ assert get_tokens_path("http://localhost:8000").name == "tokens-localhost-8000.json"
169
176
 
170
177
  def test_contains_sweatstack(self) -> None:
171
178
  """Should be in a SweatStack directory."""
@@ -2,11 +2,13 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ from typing import Any
5
6
  from unittest.mock import MagicMock, patch
6
7
 
7
8
  from typer.testing import CliRunner
8
9
 
9
10
  from sweatstack_cli.commands.auth import _display_name
11
+ from sweatstack_cli.exceptions import APIError, AuthenticationError, SecondFactorRequired
10
12
  from sweatstack_cli.main import app
11
13
 
12
14
  runner = CliRunner()
@@ -93,6 +95,34 @@ class TestStatusShowsTheConfirmation:
93
95
  assert "Passkey: not confirmed at login\n" in output
94
96
 
95
97
 
98
+ class TestStatusAsksSweatStack:
99
+ """`status` says signed in only when SweatStack accepts the sign-in, not merely when tokens exist."""
100
+
101
+ def _status(self, error: Exception) -> Any:
102
+ tokens = MagicMock(access_token=_jwt({"sub": "user_123"}))
103
+ with (
104
+ patch("sweatstack_cli.commands.auth.Authenticator") as mock_auth,
105
+ patch("sweatstack_cli.commands.auth.APIClient") as mock_client,
106
+ patch("sweatstack_cli.commands.auth.check_for_update", return_value=(False, None)),
107
+ ):
108
+ mock_auth.return_value.get_valid_tokens.return_value = tokens
109
+ mock_client.return_value.get.side_effect = error
110
+ return runner.invoke(app, ["status"])
111
+
112
+ def test_refused_tokens_are_no_sign_in(self) -> None:
113
+ result = self._status(AuthenticationError("Session expired."))
114
+ assert result.exit_code == 1
115
+ assert "Not authenticated" in result.stdout and "✓ Authenticated" not in result.stdout
116
+
117
+ def test_sweatstack_unreachable_keeps_the_sign_in(self) -> None:
118
+ result = self._status(APIError("down", status_code=503))
119
+ assert result.exit_code == 0 and "✓ Authenticated" in result.stdout
120
+
121
+ def test_a_step_up_keeps_the_sign_in(self) -> None:
122
+ result = self._status(SecondFactorRequired())
123
+ assert result.exit_code == 0 and "✓ Authenticated" in result.stdout
124
+
125
+
96
126
  class TestLogout:
97
127
  def test_logged_out(self) -> None:
98
128
  with patch("sweatstack_cli.commands.auth.Authenticator") as mock_auth:
@@ -651,7 +651,7 @@ wheels = [
651
651
 
652
652
  [[package]]
653
653
  name = "sweatstack-cli"
654
- version = "0.17.0"
654
+ version = "0.17.1"
655
655
  source = { editable = "." }
656
656
  dependencies = [
657
657
  { name = "httpx" },
File without changes