sweatstack-cli 0.12.0__py3-none-any.whl → 0.13.0__py3-none-any.whl
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/__init__.py +8 -1
- sweatstack_cli/commands/app.py +19 -12
- sweatstack_cli/commands/page.py +3 -11
- sweatstack_cli/go_live.py +45 -0
- {sweatstack_cli-0.12.0.dist-info → sweatstack_cli-0.13.0.dist-info}/METADATA +38 -9
- {sweatstack_cli-0.12.0.dist-info → sweatstack_cli-0.13.0.dist-info}/RECORD +8 -7
- {sweatstack_cli-0.12.0.dist-info → sweatstack_cli-0.13.0.dist-info}/WHEEL +0 -0
- {sweatstack_cli-0.12.0.dist-info → sweatstack_cli-0.13.0.dist-info}/entry_points.txt +0 -0
sweatstack_cli/__init__.py
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
"""SweatStack CLI — Command-line interface for the SweatStack platform."""
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
4
|
+
|
|
5
|
+
# Single source of truth: the version in pyproject.toml, read from the installed
|
|
6
|
+
# package's metadata. A hardcoded copy here drifted once (0.12.0 shipped as 0.11.0).
|
|
7
|
+
try:
|
|
8
|
+
__version__ = version("sweatstack-cli")
|
|
9
|
+
except PackageNotFoundError: # Imported from a source tree that isn't installed.
|
|
10
|
+
__version__ = "unknown"
|
sweatstack_cli/commands/app.py
CHANGED
|
@@ -12,6 +12,7 @@ import typer
|
|
|
12
12
|
from sweatstack_cli.api import APIClient
|
|
13
13
|
from sweatstack_cli.console import console, stderr_console
|
|
14
14
|
from sweatstack_cli.exceptions import APIError, AuthenticationError
|
|
15
|
+
from sweatstack_cli.go_live import app_url, print_go_live
|
|
15
16
|
from sweatstack_cli.project import CONFIG_FILENAME, write_config
|
|
16
17
|
from sweatstack_cli.services.applications import create_application
|
|
17
18
|
|
|
@@ -74,6 +75,18 @@ def create(
|
|
|
74
75
|
raise typer.Exit(1)
|
|
75
76
|
name = typer.prompt("App name")
|
|
76
77
|
|
|
78
|
+
# Protect an existing sweatstack.toml before creating anything, so declining
|
|
79
|
+
# (or a non-interactive refusal) never leaves an orphaned application behind.
|
|
80
|
+
if Path(CONFIG_FILENAME).exists():
|
|
81
|
+
if not interactive:
|
|
82
|
+
console.print(
|
|
83
|
+
f"[red]Error:[/red] {CONFIG_FILENAME} already exists. "
|
|
84
|
+
"Remove it first or run interactively."
|
|
85
|
+
)
|
|
86
|
+
raise typer.Exit(1)
|
|
87
|
+
console.print(f"[yellow]Warning:[/yellow] {CONFIG_FILENAME} already exists.")
|
|
88
|
+
typer.confirm("Overwrite?", abort=True)
|
|
89
|
+
|
|
77
90
|
# Prompt for optional fields in interactive mode
|
|
78
91
|
if interactive:
|
|
79
92
|
if description is None:
|
|
@@ -110,18 +123,7 @@ def create(
|
|
|
110
123
|
if env_path:
|
|
111
124
|
_write_env_file(env_path, result)
|
|
112
125
|
|
|
113
|
-
# Write sweatstack.toml (
|
|
114
|
-
config_path = Path(CONFIG_FILENAME)
|
|
115
|
-
if config_path.exists():
|
|
116
|
-
if not interactive:
|
|
117
|
-
console.print(
|
|
118
|
-
f"[red]Error:[/red] {CONFIG_FILENAME} already exists. "
|
|
119
|
-
"Remove it first or run interactively."
|
|
120
|
-
)
|
|
121
|
-
raise typer.Exit(1)
|
|
122
|
-
console.print(f"[yellow]Warning:[/yellow] {CONFIG_FILENAME} already exists.")
|
|
123
|
-
typer.confirm("Overwrite?", abort=True)
|
|
124
|
-
|
|
126
|
+
# Write sweatstack.toml (checked for overwrite before the app was created)
|
|
125
127
|
# Default the deploy directory to public/ so the project is deploy-ready and
|
|
126
128
|
# consistent with `page init` / `page serve` / `page deploy`.
|
|
127
129
|
config_path = write_config(
|
|
@@ -197,6 +199,11 @@ def _print_app_created(result: dict[str, str], env_path: Path | None, config_pat
|
|
|
197
199
|
console.print()
|
|
198
200
|
console.print("[yellow]Save the secret now — it won't be shown again.[/yellow]")
|
|
199
201
|
|
|
202
|
+
console.print()
|
|
203
|
+
console.print("Next: authorize with your own account. The app's overview walks you through it:")
|
|
204
|
+
console.print(f" {app_url(result['id'])}")
|
|
205
|
+
print_go_live(result)
|
|
206
|
+
|
|
200
207
|
|
|
201
208
|
@app.command()
|
|
202
209
|
def link(
|
sweatstack_cli/commands/page.py
CHANGED
|
@@ -16,9 +16,9 @@ import typer
|
|
|
16
16
|
from rich.progress import Progress, SpinnerColumn, TextColumn
|
|
17
17
|
|
|
18
18
|
from sweatstack_cli.api import APIClient
|
|
19
|
-
from sweatstack_cli.config import get_settings
|
|
20
19
|
from sweatstack_cli.console import console
|
|
21
20
|
from sweatstack_cli.exceptions import APIError, AuthenticationError
|
|
21
|
+
from sweatstack_cli.go_live import print_go_live
|
|
22
22
|
from sweatstack_cli.project import CONFIG_FILENAME, ProjectConfig, update_config, write_config
|
|
23
23
|
from sweatstack_cli.services.applications import (
|
|
24
24
|
APPLICATION_HAS_PAGE_CODE,
|
|
@@ -196,16 +196,8 @@ def deploy(
|
|
|
196
196
|
console.print(f" Files: {file_count}")
|
|
197
197
|
console.print(f" URL: {result.get('url', 'N/A')}")
|
|
198
198
|
|
|
199
|
-
#
|
|
200
|
-
|
|
201
|
-
if application.get("is_private"):
|
|
202
|
-
app_id = application.get("id")
|
|
203
|
-
if app_id:
|
|
204
|
-
base_url = get_settings().api_url
|
|
205
|
-
console.print()
|
|
206
|
-
console.print("Your app is private. Ready to go public?")
|
|
207
|
-
publish_url = f"{base_url}/applications/{app_id}/publish"
|
|
208
|
-
console.print(f" {publish_url}")
|
|
199
|
+
# What the app still needs before anyone else can connect, as the server reports it.
|
|
200
|
+
print_go_live(result.get("application") or {}, on_pages=True)
|
|
209
201
|
|
|
210
202
|
|
|
211
203
|
def _upload(
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""What an app still needs before anyone else can connect, as the CLI prints it.
|
|
2
|
+
|
|
3
|
+
The server decides: `go_live_missing` on the application in an API response is the same
|
|
4
|
+
checklist the web app's pages show (SweatStack plan 080). The CLI only prints it and links to
|
|
5
|
+
the page where each item is filled in, so a terminal, an agent and the browser agree.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from sweatstack_cli.config import get_settings
|
|
13
|
+
from sweatstack_cli.console import console
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def app_url(application_id: str, tab: str = "") -> str:
|
|
17
|
+
"""The application's page in the web app, or one of its tabs."""
|
|
18
|
+
return f"{get_settings().api_url}/applications/{application_id}{tab}"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def print_go_live(application: dict[str, Any], *, on_pages: bool = False) -> None:
|
|
22
|
+
"""Print what stands between `application` and anyone else connecting, or nothing when the
|
|
23
|
+
app is ready. A server older than the checklist sends only `is_private`; then the CLI says
|
|
24
|
+
that much and links to the same page."""
|
|
25
|
+
application_id = application.get("id")
|
|
26
|
+
if not application_id:
|
|
27
|
+
return
|
|
28
|
+
missing = [item["label"] for item in application.get("go_live_missing") or []]
|
|
29
|
+
private = bool(application.get("is_private"))
|
|
30
|
+
if not missing and not private:
|
|
31
|
+
return
|
|
32
|
+
|
|
33
|
+
console.print()
|
|
34
|
+
if private:
|
|
35
|
+
console.print("Your app is private: only you can connect.")
|
|
36
|
+
else:
|
|
37
|
+
console.print("Your app is public, but anyone else is turned away until you add:")
|
|
38
|
+
if missing:
|
|
39
|
+
if private:
|
|
40
|
+
console.print("Before anyone else can, add:")
|
|
41
|
+
for label in missing:
|
|
42
|
+
console.print(f" - {label}")
|
|
43
|
+
if private and on_pages:
|
|
44
|
+
console.print("Runs entirely in the browser? The Pages fast track fills in most of it.")
|
|
45
|
+
console.print(f" {app_url(application_id, '/consent')}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: sweatstack-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.13.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
|
|
@@ -67,8 +67,11 @@ uv tool install --reinstall sweatstack-cli
|
|
|
67
67
|
# Authenticate with SweatStack
|
|
68
68
|
sweatstack login
|
|
69
69
|
|
|
70
|
-
# Create an app and
|
|
71
|
-
sweatstack
|
|
70
|
+
# Create an app with a page, and scaffold public/index.html
|
|
71
|
+
sweatstack page init "My App"
|
|
72
|
+
|
|
73
|
+
# Preview locally, then publish to https://my-app.pages.sweatstack.dev
|
|
74
|
+
sweatstack page serve
|
|
72
75
|
sweatstack page deploy
|
|
73
76
|
```
|
|
74
77
|
|
|
@@ -110,7 +113,7 @@ sweatstack page deploy
|
|
|
110
113
|
|
|
111
114
|
### Project Configuration
|
|
112
115
|
|
|
113
|
-
|
|
116
|
+
`app create`, `app link` and `page init` generate a `sweatstack.toml` in the current directory. Other commands read defaults from this file.
|
|
114
117
|
|
|
115
118
|
```toml
|
|
116
119
|
[app]
|
|
@@ -122,9 +125,33 @@ slug = "my-page"
|
|
|
122
125
|
directory = "dist"
|
|
123
126
|
```
|
|
124
127
|
|
|
125
|
-
###
|
|
128
|
+
### Pages
|
|
129
|
+
|
|
130
|
+
Static sites hosted at `https://<slug>.pages.sweatstack.dev`. Each application has at most one page.
|
|
131
|
+
|
|
132
|
+
| Command | Description |
|
|
133
|
+
|---------|-------------|
|
|
134
|
+
| `sweatstack page init [NAME]` | Create an app and its page, and scaffold `public/index.html` |
|
|
135
|
+
| `sweatstack page serve` | Preview the site locally |
|
|
136
|
+
| `sweatstack page deploy [SLUG]` | Publish the site, creating the page if needed |
|
|
137
|
+
|
|
138
|
+
#### `page init`
|
|
139
|
+
|
|
140
|
+
Creates a private application and its page, records both in `sweatstack.toml`, and writes a starter app to `public/index.html` that signs in with SweatStack and plots your latest activity. The slug is derived from the name. With an app already linked in `sweatstack.toml`, it reuses that app instead of creating one.
|
|
126
141
|
|
|
127
|
-
|
|
142
|
+
| Option | Description |
|
|
143
|
+
|--------|-------------|
|
|
144
|
+
| `--slug TEXT` | Page slug (default: derived from the name) |
|
|
145
|
+
| `--dir PATH` | Directory to scaffold (default: `public`) |
|
|
146
|
+
| `--title TEXT` | Title shown on the page (default: the name) |
|
|
147
|
+
| `--client-id TEXT` | Reuse an existing application |
|
|
148
|
+
| `--force, -f` | Overwrite an existing `index.html` |
|
|
149
|
+
|
|
150
|
+
#### `page serve`
|
|
151
|
+
|
|
152
|
+
Serves the `[page] directory` from `sweatstack.toml` on the first free port from 8000. Extra arguments are passed to `python -m http.server`. Apps created by the CLI accept sign-in redirects to localhost on any port.
|
|
153
|
+
|
|
154
|
+
#### `page deploy`
|
|
128
155
|
|
|
129
156
|
```bash
|
|
130
157
|
# Deploy using sweatstack.toml defaults (recommended)
|
|
@@ -134,9 +161,11 @@ sweatstack page deploy
|
|
|
134
161
|
sweatstack page deploy my-page --dir ./dist
|
|
135
162
|
```
|
|
136
163
|
|
|
137
|
-
If the page doesn't exist yet, `deploy` creates it. With an app linked in
|
|
138
|
-
|
|
139
|
-
|
|
164
|
+
Every deploy replaces all files on the page. If the page doesn't exist yet, `deploy` creates it. With an app linked in `sweatstack.toml`, it creates that app's page. Without one, it asks to create a new app with the page, and fails instead when not run interactively (e.g. in CI).
|
|
165
|
+
|
|
166
|
+
New apps are private: only you can sign in. After deploying, `deploy` prints a link to make the app public.
|
|
167
|
+
|
|
168
|
+
**Limits:** 10 MB per file; 100 MB and about 1,000 files per deploy.
|
|
140
169
|
|
|
141
170
|
## License
|
|
142
171
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
sweatstack_cli/__init__.py,sha256=
|
|
1
|
+
sweatstack_cli/__init__.py,sha256=FalqkgMa69vADPpNY76Cztq5oiLgzRNVlhaR4itdZ78,465
|
|
2
2
|
sweatstack_cli/config.py,sha256=cD4OXnVAKVagYazyk9Cw-WWx62tJPqcjQt1cknYyymM,706
|
|
3
3
|
sweatstack_cli/console.py,sha256=69KWAM7ksnYRTONMYTXGXN4LWRAQhRxcLXO0LcWGLqo,300
|
|
4
4
|
sweatstack_cli/exceptions.py,sha256=VKV6KVhztfGRmj5jLKnqY0PEBD1qJGEg1ePuKY9rn_o,1334
|
|
5
|
+
sweatstack_cli/go_live.py,sha256=6-WjN9jyfLnbLXs0eAEX0NkwWeigf1A7BYVGG6W092w,1855
|
|
5
6
|
sweatstack_cli/main.py,sha256=obcF1VGhwcE_pI1BwTJkY4J4BgIGac-y3yYGvY6ZOp8,2330
|
|
6
7
|
sweatstack_cli/project.py,sha256=yUpkrEbPD2c0lu8IKw88aQrkFtksLHMjmgHlaqKVQUo,3660
|
|
7
8
|
sweatstack_cli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -14,13 +15,13 @@ sweatstack_cli/auth/jwt.py,sha256=Ja6ccFyRKtX5MPjFdHNavVYf8KTz0MYT86StbnF-cwg,15
|
|
|
14
15
|
sweatstack_cli/auth/pkce.py,sha256=sO_xUeN1UIvXKX0yEIGgMTIIzvfCOCUwlyNAveEd16k,1542
|
|
15
16
|
sweatstack_cli/auth/tokens.py,sha256=kc8ytoO9PAyjLD6wUTIagVuP7_ia5ZjW5m_WjXIRIkA,4942
|
|
16
17
|
sweatstack_cli/commands/__init__.py,sha256=YCO8wYVvdGeoEI0p_oUm8ANLneuET4SHsKDjitMjAgY,35
|
|
17
|
-
sweatstack_cli/commands/app.py,sha256=
|
|
18
|
+
sweatstack_cli/commands/app.py,sha256=90AwUm5RhagE5tZww77Fk9B0vpZFlC59OlylGXTxWC0,9055
|
|
18
19
|
sweatstack_cli/commands/auth.py,sha256=kkSZoWFTUw9Mo30FA_bOJxduWC1nuvkl_m1qtrtSj4I,3905
|
|
19
|
-
sweatstack_cli/commands/page.py,sha256=
|
|
20
|
+
sweatstack_cli/commands/page.py,sha256=G58KEsiCeq4hD0Z5ot2g9W6vBH6iZu-lCvdA1kzep-U,24612
|
|
20
21
|
sweatstack_cli/services/__init__.py,sha256=pFrcjumdHNRU8aa3bxplq4jhCivH2YGGqkGG8yIMv20,337
|
|
21
22
|
sweatstack_cli/services/applications.py,sha256=VToXlk48kn2-39eTdDf_hSJUdZqkJjCFoDaqf6DpdGA,4428
|
|
22
23
|
sweatstack_cli/templates/page/index.html,sha256=vOnZnIstf252XLiQ6GBznVp5dSy5SqpSwRUfJT43bbQ,17374
|
|
23
|
-
sweatstack_cli-0.
|
|
24
|
-
sweatstack_cli-0.
|
|
25
|
-
sweatstack_cli-0.
|
|
26
|
-
sweatstack_cli-0.
|
|
24
|
+
sweatstack_cli-0.13.0.dist-info/METADATA,sha256=D0md2zThfT3J3yDShj0E9bO93viZqYoT6gEoZH55YhI,5531
|
|
25
|
+
sweatstack_cli-0.13.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
26
|
+
sweatstack_cli-0.13.0.dist-info/entry_points.txt,sha256=rnH0EV1U9CQlmKQcJ7RmxGpNRTa9J-YdiIJZDYrAXb4,56
|
|
27
|
+
sweatstack_cli-0.13.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|