One installation per project, and no login to reach it
Two things a local install should not have asked for. `fluksio serve` now signs you in. Logging in to your own machine was a formality — the password was printed by the same process that would have checked it, and the database it authenticates against sits in the directory the token goes into — so `serve` mints the token itself and says where it put it. `fluksio login` is left for an engine somewhere else. And an installation is `.fluksio` beside the code, found the way `.git` is, rather than one `~/.fluksio` for the machine. A repository with its own venv was already getting its own engine; it now gets its own flows, run history and token too, instead of three repositories sharing one database and fighting over one port. `--global` asks for the shared one, `--data-dir` still names any directory, and when both exist the banner says which you are looking at and how to reach the other. The directory ignores itself from within — a `.gitignore` of `*`, the way uv writes one into `.venv` — because it holds a credential and a database, and neither belongs in anybody's history. The token is written mode 600. A login an older version wrote to ~/.config/fluksio is still read, so nothing that worked stops working. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012ue1tkFWB1bcGy3aWhCKpU
This commit is contained in:
@@ -17,9 +17,10 @@ from typing import Any
|
||||
|
||||
from fluksio.sdk import FLOWS, Flow, SyncError
|
||||
from fluksio.sdk.client import (
|
||||
GLOBAL_DATA_DIR,
|
||||
ApiError,
|
||||
Client,
|
||||
config_path,
|
||||
data_dir,
|
||||
login,
|
||||
origin_of,
|
||||
repo_root,
|
||||
@@ -104,13 +105,15 @@ def discover(targets: list[str]) -> list[Flow]:
|
||||
|
||||
|
||||
def cmd_login(args: argparse.Namespace) -> int:
|
||||
"""Only needed for an engine somewhere else — `serve` signs you in here."""
|
||||
email = args.email or input("Email: ")
|
||||
password = args.password or getpass.getpass("Password: ")
|
||||
directory = GLOBAL_DATA_DIR.expanduser() if args.shared else data_dir()
|
||||
try:
|
||||
login(args.url, email, password)
|
||||
path = login(args.url, email, password, directory=directory)
|
||||
except ApiError as exc:
|
||||
return _fail(f"could not log in: {exc.detail}")
|
||||
_say(f"Logged in to {args.url}; the token is in {config_path()}.")
|
||||
_say(f"Logged in to {args.url}; the token is in {path}.")
|
||||
return 0
|
||||
|
||||
|
||||
@@ -263,10 +266,18 @@ def add_parsers(subparsers: Any) -> None:
|
||||
)
|
||||
sub.add_argument("--token", default="", help="override the stored token")
|
||||
|
||||
parser = subparsers.add_parser("login", help="store a token for an engine")
|
||||
parser = subparsers.add_parser(
|
||||
"login", help="store a token for an engine elsewhere"
|
||||
)
|
||||
parser.add_argument("--url", default="http://localhost:8000")
|
||||
parser.add_argument("--email", default="")
|
||||
parser.add_argument("--password", default="")
|
||||
parser.add_argument(
|
||||
"--global",
|
||||
dest="shared",
|
||||
action="store_true",
|
||||
help="store it for the machine rather than this project",
|
||||
)
|
||||
parser.set_defaults(func=cmd_login)
|
||||
|
||||
parser = subparsers.add_parser(
|
||||
|
||||
Reference in New Issue
Block a user