publisher, deployer: same path logic as the originals
build / build (push) Successful in 21m27s

The packaged copies use config.default_path() and pipeline._history_path():
files next to the sources in a checkout, ~/.config/<name> and
~/.local/state/<name> when installed. The copies now differ from the
originals only in the neutral defaults.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
das
2026-10-25 14:55:40 +02:00
co-authored by Claude Sonnet 5.5
parent 396986aaf4
commit 60af93df74
7 changed files with 41 additions and 7 deletions
@@ -148,7 +148,7 @@ def main(argv=None) -> int:
args = p.parse_args(argv)
color(sys.stdout.isatty() and not args.no_color)
cfg_path = Path(args.config) if args.config else Path(__file__).resolve().parent.parent / "deploy.toml"
cfg_path = Path(args.config) if args.config else config.default_path()
try:
cfg = config.load(cfg_path)
except (OSError, config.ConfigError) as e:
@@ -211,3 +211,11 @@ def append_apps(path: Path, apps: list[App], drafts: list[App] = ()) -> None:
block = "".join(f"# {line}\n" for line in app_to_toml(a).splitlines())
text = text.rstrip("\n") + "\n\n# TODO: check src / build / dest, then uncomment\n" + block
path.write_text(text)
def default_path() -> Path:
"""deploy.toml next to the sources (a checkout), else ~/.config/deployer/deploy.toml (an installed package)."""
local = Path(__file__).resolve().parent.parent / "deploy.toml"
if local.exists():
return local
return Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config") / "deployer" / "deploy.toml"
@@ -13,8 +13,17 @@ from . import kinds, remote, snapshots
from .config import App, Config
from .kinds import Options, Plan
# Das OS package: /usr/lib is read-only, so the history goes to the user's state dir
HISTORY = Path(os.environ.get("XDG_STATE_HOME") or Path.home() / ".local/state") / "deployer" / "history.log"
def _history_path() -> Path:
"""history.log next to the sources (a checkout), else ~/.local/state/deployer/ (an installed package)."""
local = Path(__file__).resolve().parent.parent
if os.access(local, os.W_OK):
return local / "history.log"
return Path(os.environ.get("XDG_STATE_HOME") or Path.home() / ".local/state") / "deployer" / "history.log"
HISTORY = _history_path()
class DeployError(RuntimeError):
@@ -150,7 +150,7 @@ def main(argv=None) -> int:
args = p.parse_args(argv)
global COLOR
COLOR = sys.stdout.isatty() and not args.no_color
cfg_path = Path(args.config) if args.config else Path(__file__).resolve().parent.parent / "publish.toml"
cfg_path = Path(args.config) if args.config else config.default_path()
try:
cfg = config.load(cfg_path)
except (OSError, config.ConfigError) as e:
@@ -185,3 +185,11 @@ def append_apps(path: Path, apps: list[App]) -> None:
validate_app(a)
text = text.rstrip("\n") + "\n\n" + app_to_toml(a)
path.write_text(text)
def default_path() -> Path:
"""publish.toml next to the sources (a checkout), else ~/.config/publisher/publish.toml (an installed package)."""
local = Path(__file__).resolve().parent.parent / "publish.toml"
if local.exists():
return local
return Path(os.environ.get("XDG_CONFIG_HOME") or Path.home() / ".config") / "publisher" / "publish.toml"
@@ -13,8 +13,17 @@ from . import packages, remote
from .config import App, Config
from .packages import Kind, Local, Published, version_key
# Das OS package: /usr/lib is read-only, so the history goes to the user's state dir
HISTORY = Path(os.environ.get("XDG_STATE_HOME") or Path.home() / ".local/state") / "publisher" / "history.log"
def _history_path() -> Path:
"""history.log next to the sources (a checkout), else ~/.local/state/publisher/ (an installed package)."""
local = Path(__file__).resolve().parent.parent
if os.access(local, os.W_OK):
return local / "history.log"
return Path(os.environ.get("XDG_STATE_HOME") or Path.home() / ".local/state") / "publisher" / "history.log"
HISTORY = _history_path()
# Plan item actions; the first five change the server
NEW, REPLACE, META, NOTES, DELETE, SAME, SKIP = "new", "replace", "meta", "notes", "delete", "same", "skip"