Skip to content

Commit c3976bc

Browse files
committed
feat: add sprag types CLI command and improve error messages
New command: - sprag types: generates .sprag/types.pyi from the build manifest with type aliases for routes, mounts, actions, stores, and modules Build pipeline: - Auto-generate types.pyi during sprag build and sprag dev - Add stores to the serializable manifest - New _serializable_stores() helper in build.py Scaffolding: - Add _shared template directory support with merge_existing - _render_template_dir() now supports merge_existing flag - _merge_gitignore() helper for shared .gitignore templates Error messages: - Improved error messages across browser.py (debounce, throttle, virtual_scroll, infinite_scroll, ref), assets.py (module, normalize), mount.py, page.py, socket_bridge.py, stores.py Type declarations: - Added docstring to App dataclass - Added docstring to Page dataclass - Type stub hint in browser.py module docstring Docs: - Added sprag types to README.md CLI section - Added full sprag types section to CLI reference docs
1 parent 1b19efb commit c3976bc

40 files changed

Lines changed: 2077 additions & 22 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ sprag dev [--port 8000]
8787
sprag build # full app (server + client)
8888
sprag build static # pre-rendered static site
8989
sprag pack # minify, bytecode-compile, optimize images
90+
sprag types # generate .sprag/types.pyi from the build manifest
9091
sprag add route|mount|content <name>
9192
sprag routes # list all surfaces
9293
sprag inspect /path # show compiled output for a route

docs/app/content/docs/reference/cli.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,33 @@ sprag pack [--dist dist] [--zip] [--dry-run] [--verbose]
118118
sprag pack --dist dist --zip --skip-images
119119
```
120120

121+
## `sprag types`
122+
123+
Generate a `.sprag/types.pyi` file from the current build manifest. The generated file
124+
contains type aliases for routes, mounts, actions, stores, and module aliases — useful for
125+
IDE autocompletion and type-safe dispatch.
126+
127+
**Usage**
128+
129+
```bash
130+
sprag types [--output PATH]
131+
```
132+
133+
**Flags**
134+
135+
- `--output` — directory where `types.pyi` will be written (default: `.sprag`)
136+
- `--app` — explicit app import target
137+
- `--project-root` — project root to load from
138+
139+
**Example**
140+
141+
```bash
142+
sprag types
143+
```
144+
145+
The command reads `manifest.json` from the output directory and writes `types.pyi` alongside
146+
it. It is also run automatically as part of `sprag build` and `sprag dev`.
147+
121148
## `sprag add route`
122149

123150
Scaffold a new route under `app/routes/`.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ version = {attr = "sprag.__version__"}
5050
include = ["sprag", "sprag.*"]
5151

5252
[tool.setuptools.package-data]
53-
sprag = ["assets/**/*", "dev/templates/**/*.tmpl"]
53+
sprag = ["assets/**/*", "dev/templates/**/*.tmpl", "py.typed", "**/*.pyi"]

0 commit comments

Comments
 (0)