sweatstack-cli 0.9.0__tar.gz → 0.10.0__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.
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/PKG-INFO +1 -1
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/pyproject.toml +1 -1
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/__init__.py +1 -1
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/commands/page.py +67 -2
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/sweatstack.toml +3 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/uv.lock +1 -1
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/.claude/settings.local.json +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/.claude/skills/sweatstack/SKILL.md +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/.claude/skills/sweatstack/api.md +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/.claude/skills/sweatstack/auth.md +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/.claude/skills/sweatstack/cli.md +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/.claude/skills/sweatstack/pyscript.md +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/.claude/skills/sweatstack/webapp.md +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/.gitignore +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/.python-version +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/CREATE_PRIVATE_APP.md +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/DEVELOPMENT.md +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/Makefile +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/PLAN.md +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/README.md +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/api/__init__.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/api/client.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/auth/__init__.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/auth/callback_server.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/auth/jwt.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/auth/pkce.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/auth/tokens.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/commands/__init__.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/commands/app.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/commands/auth.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/config.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/console.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/exceptions.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/main.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/project.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/py.typed +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/src/sweatstack_cli/version_check.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/tests/__init__.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/tests/conftest.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/tests/test_api/__init__.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/tests/test_api/test_client.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/tests/test_auth/__init__.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/tests/test_auth/test_callback_server.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/tests/test_auth/test_jwt.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/tests/test_auth/test_pkce.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/tests/test_auth/test_tokens.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/tests/test_commands/__init__.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/tests/test_commands/test_app.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/tests/test_commands/test_cli.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/tests/test_project.py +0 -0
- {sweatstack_cli-0.9.0 → sweatstack_cli-0.10.0}/tests/test_version_check.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sweatstack-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.10.0
|
|
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.
|
|
3
|
+
version = "0.10.0"
|
|
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" }]
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
"""Page commands: deploy static sites."""
|
|
1
|
+
"""Page commands: deploy and serve static sites."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import mimetypes
|
|
6
|
+
import socket
|
|
7
|
+
import subprocess
|
|
6
8
|
import sys
|
|
7
9
|
from pathlib import Path
|
|
8
10
|
|
|
@@ -117,7 +119,7 @@ def deploy(
|
|
|
117
119
|
f"Deploying to '{slug}' but "
|
|
118
120
|
f"{CONFIG_FILENAME} has slug '{config.page.slug}'"
|
|
119
121
|
)
|
|
120
|
-
if config.page.directory and rel_dir != config.page.directory:
|
|
122
|
+
if config.page.directory and rel_dir != config.page.directory.rstrip("/"):
|
|
121
123
|
mismatches.append(
|
|
122
124
|
f"Deploying '{rel_dir}' but "
|
|
123
125
|
f"{CONFIG_FILENAME} has directory '{config.page.directory}'"
|
|
@@ -211,3 +213,66 @@ def deploy(
|
|
|
211
213
|
console.print("Your app is private. Ready to go public?")
|
|
212
214
|
publish_url = f"{base_url}/applications/{app_id}/publish"
|
|
213
215
|
console.print(f" {publish_url}")
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def _find_available_port(start: int = 8000, max_attempts: int = 100) -> int:
|
|
219
|
+
"""Find the first available port starting from `start`."""
|
|
220
|
+
for port in range(start, start + max_attempts):
|
|
221
|
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
|
222
|
+
try:
|
|
223
|
+
s.bind(("localhost", port))
|
|
224
|
+
return port
|
|
225
|
+
except OSError:
|
|
226
|
+
continue
|
|
227
|
+
console.print(f"[red]Error:[/red] No available port found in range {start}-{start + max_attempts - 1}.")
|
|
228
|
+
raise typer.Exit(1)
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
@app.command(
|
|
232
|
+
context_settings={"allow_extra_args": True, "allow_interspersed_args": False},
|
|
233
|
+
)
|
|
234
|
+
def serve(
|
|
235
|
+
ctx: typer.Context,
|
|
236
|
+
) -> None:
|
|
237
|
+
"""Serve the static site locally using Python's http.server.
|
|
238
|
+
|
|
239
|
+
Extra arguments are passed through to python -m http.server.
|
|
240
|
+
"""
|
|
241
|
+
config = ProjectConfig.load()
|
|
242
|
+
if not config or not config.page.directory:
|
|
243
|
+
console.print(
|
|
244
|
+
f"[red]Error:[/red] No directory configured in {CONFIG_FILENAME}."
|
|
245
|
+
)
|
|
246
|
+
console.print(f"Add a [page] section with a directory to {CONFIG_FILENAME}.")
|
|
247
|
+
raise typer.Exit(1)
|
|
248
|
+
|
|
249
|
+
directory = Path(config.page.directory)
|
|
250
|
+
if not directory.is_dir():
|
|
251
|
+
console.print(f"[red]Error:[/red] '{directory}' is not a directory.")
|
|
252
|
+
raise typer.Exit(1)
|
|
253
|
+
|
|
254
|
+
extra_args = ctx.args
|
|
255
|
+
|
|
256
|
+
# http.server takes port as a positional arg — check if user already passed one
|
|
257
|
+
has_port_arg = any(not arg.startswith("-") for arg in extra_args)
|
|
258
|
+
port_args: list[str] = []
|
|
259
|
+
if not has_port_arg:
|
|
260
|
+
port = _find_available_port()
|
|
261
|
+
port_args = [str(port)]
|
|
262
|
+
|
|
263
|
+
cmd = [
|
|
264
|
+
sys.executable, "-m", "http.server",
|
|
265
|
+
"--directory", str(directory),
|
|
266
|
+
*port_args,
|
|
267
|
+
*extra_args,
|
|
268
|
+
]
|
|
269
|
+
|
|
270
|
+
if not has_port_arg:
|
|
271
|
+
console.print(f"Serving [bold]{directory}[/bold] at [cyan]http://localhost:{port}[/cyan]")
|
|
272
|
+
else:
|
|
273
|
+
console.print(f"Serving [bold]{directory}[/bold]")
|
|
274
|
+
|
|
275
|
+
try:
|
|
276
|
+
raise SystemExit(subprocess.call(cmd))
|
|
277
|
+
except KeyboardInterrupt:
|
|
278
|
+
pass
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|