Commit Graph
126 Commits
Author SHA1 Message Date
LeoVasanko cbce326798 Clean up partial artifacts when create-vue is aborted
ensure_frontend now removes whatever create-vue wrote before failing:
the whole frontend/ dir if it didn't pre-exist, otherwise only the
files it added (pre-existing content is kept). If cmd_setup created the
project directory itself, that is removed too, so an aborted run leaves
no trace.
v1.7.5
2026-10-27 22:44:17 +00:00
LeoVasanko 218c9e203b Abort setup when create-vue is interrupted or cancelled
create-vue exits 0 when its prompts are cancelled, so a zero return code
is not proof of success: also require frontend/package.json to exist, and
treat Ctrl-C (KeyboardInterrupt) as failure instead of a traceback. The
caller already exits 1 on failure, so the setup no longer continues with
a missing or partial frontend.
2026-10-27 22:40:35 +00:00
LeoVasanko c9557d4308 Prefer npm over deno/bun and validate Node.js version, matching template buildutil
Auto-detect now tries npm, deno, bun (was deno-first), and npm is only
accepted when the adjacent node is v20+. Same checks apply to JS_RUNTIME,
which maps node to npm as before.
2026-10-27 22:39:56 +00:00
LeoVasanko 372d249a85 Fix setup for new uv init layouts; use backend/ package dir for new projects v1.7.4 2026-10-27 22:19:22 +00:00
LeoVasanko a19c9028c5 Detect color support on stderr, matching where logs are written 2026-10-21 19:49:20 +00:00
LeoVasanko 465206067b Expose WebSocket connection id as ws.state.logid on accept
Store the two-digit WS id (colored when stderr supports color, plain
otherwise) in the ASGI scope state so user code can include it in its
own log lines via websocket.state.logid.

Move terminal helpers (use_color, strip_ansi, display width) into a new
dependency-free fastapi_vue.tty module, absorbing termwidth.py, to keep
imports one-directional and avoid the logging/accesslog cycle.
v1.7.3
2026-10-21 19:40:24 +00:00
LeoVasanko c869783b0b Build/dev emoji logging improved. Restored old plain lines, using intentionally different emoji than the main package. v1.7.2 2026-09-18 17:36:17 +00:00
LeoVasanko c7577e9ff7 Guard access log lines against unreset injected colors
App-supplied extra fields may carry raw ANSI color codes without a
reset, bleeding into the next line's IP column and following output.
Ensure access log lines begin and end with a reset, adding one only
where missing to avoid duplicate resets on well-formed lines.
2026-09-18 11:07:36 +00:00
LeoVasanko fa287eba20 Make buildutil logging use same emojis as the main fastapi-vue logging. v1.7.1 2026-09-18 02:52:52 +00:00
LeoVasanko 0f5b526df6 Add public setup_logging() for standalone pretty logging
Optionally usable early in CLI mains, devservers and scripts that log
before (or without) server.run().  Shares patch_log_config with the
server path (same log_config overrides), but installs no server-side
patches: Formatter gains an install flag gating the lifespan/error
middleware monkeypatches, and the NullHandler backdoor is skipped.
dev=None follows env.dev for the root level, True/False override it.
Pre-existing loggers survive the dictConfig (disable_existing_loggers
is set False).
2026-09-18 02:49:16 +00:00
LeoVasanko 1d4a0a5422 Add env() config binding with teleport() for CLI-to-worker config passing v1.7.0 2026-09-17 02:54:08 +00:00
LeoVasanko 69a1ba3239 Clean up README 2026-09-17 00:25:53 +00:00
LeoVasanko d1e82b5955 Treat dict log_config without a version key as an overlay on uvicorn defaults.
A partial log_config (no "version" key) is deep-merged over uvicorn's
default config before our patching, so users pass only their
customizations, e.g. log_config={"loggers": {"myapp": {"level":
"DEBUG"}}}.  Previously such dicts crashed at startup: dictConfig
requires a version, and our root entry referenced a "default" handler
that might not exist; that reference is now only added when the handler
exists.  The stock default formatter is replaced only when untouched,
so an overlaid fmt survives.  Dicts with version and non-dict configs
behave as before.  Documented in the README logging section, with tests
under fastapi-vue/tests (each patched config validated through
dictConfig).
v1.6.2
2026-09-16 03:57:44 +00:00
LeoVasanko 5730e5dd01 Document logging principles under the server section. 2026-09-16 02:52:46 +00:00
LeoVasanko 3a9c5d1674 Set root logger level by dev mode, drop kanta logging config.
The root logger entry patch_log_config adds now uses INFO in dev and
WARNING in production (Python's default), so third-party library INFO
noise stays silent in production while subloggers remain free to
define their own level overrides.  A user-supplied root level still
wins (setdefault).

staticfiles now logs via its own module logger instead of
uvicorn.error: the startup stats line shows in dev (root INFO) and is
hidden in production, and it no longer passes through the
uvicorn-quiet filter that silently ate it.

The kanta logger/handler/formatter block is removed: kanta configures
its own event loggers at import time as of its logging rework, and its
diagnostics follow the root logger like any other library.
2026-09-16 02:22:35 +00:00
LeoVasanko 22d9fe350b Migrate pre-1.6 DEVMODE to fastapi_vue.env with in-place patching, run uv sync after dependency changes. v1.6.1 2026-09-14 04:22:24 +00:00
LeoVasanko 42adf6120d Replace startupbox in code box with an actual screenshot. 2026-09-14 03:38:36 +00:00
LeoVasanko 5ab12187bd Add new screenshot of a simulated My App run. 2026-09-14 03:05:17 +00:00
LeoVasanko 5d1ba2f58c Add README images. v1.6.0 2026-09-14 02:26:50 +00:00
LeoVasanko cf2957ab8d Add images for docs. 2026-09-14 02:19:03 +00:00
LeoVasanko fbfd2ba1bb Rewritten fastapi-vue-setup README. 2026-09-14 01:48:26 +00:00
LeoVasanko ff33df0ebc Rewritten fastapi-vue README. Add listen URLs on startup box default template. 2026-09-13 22:59:48 +00:00
LeoVasanko dec5191157 Add fastapi_vue.env accessor with FASTAPI_VUE prefix 2026-09-13 21:24:51 +00:00
LeoVasanko baab37ae2d Startup box improvements. 2026-09-13 06:04:10 +00:00
LeoVasanko ab2d721723 Devutil ready() now logs and raises RuntimeError on timeout. 2026-09-13 05:36:40 +00:00
LeoVasanko 2d7e119161 server: listen on both loopback families for localhost.
Bind sockets ourselves and pass them to uvicorn (Server.serve(sockets) or the
ChangeReload/Multiprocess supervisors, same API uvicorn.run uses). localhost
expands to 127.0.0.1 and ::1 so clients reach the server regardless of how
localhost resolves; individual bind failures degrade with a warning. Reload
mode now serves all endpoints instead of only the first, multi-endpoint
configs no longer run lifespan twice, and unix sockets are cleaned up on
exit.
2026-09-13 05:36:40 +00:00
LeoVasanko d4f835428b Update vite-plugin-fastapi.js formatting to match modern vue/prettier/biome defaults. 2026-09-13 04:32:02 +00:00
LeoVasanko 1a22ec9dce devutil template made fully compatible and ruff-clean across python 3.11-3.14 target projects. 2026-09-13 04:12:13 +00:00
LeoVasanko 02b3890cd3 Proper error messages on npm and port check failures, avoid leaking asyncio tasks. v1.5.0 2026-09-12 05:50:52 +00:00
LeoVasanko 4c0be1bfa7 Forward extra args to create-vue, e.g. for no-interactive use. 2026-09-12 05:15:50 +00:00
LeoVasanko beca6806ef Tidy up HTTP client; nowadays we have UTF-8 headers. 2026-09-12 04:56:18 +00:00
LeoVasanko c25835f467 Rewritten devutil.ProcessGroup with proper handling of subprocess deaths
- Terminates instantly when vital process dies (e.g. backend doesn't start)
- Derived of TaskGroup, augmenting its functionality with similar semantics
2026-09-12 04:48:03 +00:00
LeoVasanko 38d5402045 Enable colored access log, tracerite and other software when running under systemd/journald which support colors (journalctl -ocat) and can strip them off (any other output mode). Sets environment FORCE_COLOR to full color if conditions are met. This is intended to affect all other modules and child processes alike (set NO_COLOR or FORCE_COLOR to override). v1.4.2 2026-09-03 17:27:48 +00:00
LeoVasanko 4f09622241 Suppress watchfiles "INFO: 1 change detected" which is useless given we already get a WARNING about which file and Reloading... v1.4.1 2026-09-02 13:56:25 +00:00
LeoVasanko 372d91bf49 Pin fastapi-vue minimum patch version to that of fastapi-vue-setup when ran, to force upgrades. 2026-08-31 21:14:04 +00:00
LeoVasanko b0b216b784 Run backend as module (python -m) in devserver instead of PATH-installed CLI. v1.4.0 2026-08-31 20:26:30 +00:00
LeoVasanko 475a2cdc3c Cleaner and non-deprecated typing for template app module. Avoids ruff errors with strict configurations. 2026-08-31 20:14:39 +00:00
LeoVasanko 8774224545 Apply lifespan error logging patch in reload/worker subprocesses too. 2026-08-31 20:04:25 +00:00
LeoVasanko cb742000a8 Render debug-mode HTTP errors with tracerite, replacing Starlette's formatter. 2026-08-31 20:00:39 +00:00
LeoVasanko be8dc0c513 Don't clear screen on vite startup as that hides our own startup banner. 2026-08-31 19:53:22 +00:00
LeoVasanko e4c21109d9 Prettier logging of errors in lifespan startup/shutdown. 2026-08-31 19:23:59 +00:00
LeoVasanko 1287ba4077 Load tracerite for devserver script too. 2026-08-31 19:23:07 +00:00
LeoVasanko 9c51b89226 Make missing frontend files non-fatal: log an error and serve the placeholder page instead of raising during lifespan startup 2026-08-31 18:48:27 +00:00
LeoVasanko d5e94a2186 Startup box: server.run() prints app name, version and connect URL in a rounded unicode box on stderr. Shared termwidth module for ANSI-aware unicode display width and padding. 2026-08-31 18:22:06 +00:00
LeoVasanko c65d8eaa12 Target project no longer depends on httpx but depends on ~matching fastapi-vue version. Ruff cleanup. 2026-08-31 17:07:49 +00:00
LeoVasanko cb0b1f067d A hack to silence INFO level log chatter from uvicorn, while still doing this via log config. 2026-08-31 16:22:16 +00:00
LeoVasanko 5dbe9a0dcd Ignore executable flag of the temporary file being used to build devserver script. 2026-08-31 15:52:56 +00:00
LeoVasanko 0bba199376 Implement a pretty logging config by default. Emoji levels. Fixes root logger info being lost and warning+ printing with lastResort without any formatting. Replaces uvicorn's default formatter and log config that the author is not willing to fix (any time soon). 2026-08-31 15:52:23 +00:00
LeoVasanko 4232304a00 Added TraceRite CLI error logging. Simplified logging setup. 2026-08-31 05:34:33 +00:00
LeoVasanko 77a34753d9 Add colored HTTP/WebSocket access logging to fastapi_vue.server.
run() gains access_log (default on) and log_config parameters.  When
enabled, uvicorn's own access log is disabled (access_log=False) and
replaced by an ASGI middleware (adapted from the uvicorn access-log
branch) that logs colored request lines, WebSocket open/close pairs,
and pre-accept rejections in open format.

log_config dicts (uvicorn's default or user-supplied) are patched
best-effort via a registered patch pipeline in fastapi_vue.logging:
swapping in our AccessFormatter, routing our output to a private
fastapi_vue.access logger (uvicorn gates its protocol-level access
logging on uvicorn.access.hasHandlers(), so that logger must stay
handlerless), and filtering stock WebSocket handshake chatter from
uvicorn.error.  Non-dict or structurally unexpected configs pass
through untouched.

The middleware is installed by patching Config.load/load_app, hooked
into AccessFormatter instantiation so reload/worker subprocesses
(which re-apply log_config without re-calling run()) are covered.
2026-08-31 04:16:43 +00:00