Skip to content

Commit 6798e8e

Browse files
authored
Merge pull request #16 from ElcanoTek/codex/setup-victoria-file-and-clean-temporary-files
Store docs and config in Victoria home
2 parents 030aa35 + 3149633 commit 6798e8e

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

victoria.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def resource_path(name: str) -> Path:
4444
return base / name
4545

4646
def ensure_default_files():
47-
for fname in [CONFIG_TEMPLATE, SNOWFLAKE_FRAG, ".crushignore"]:
47+
for fname in [".crushignore", "CRUSH.md"]:
4848
src = resource_path(fname)
4949
dst = APP_HOME / fname
5050
if src.exists() and not dst.exists():
@@ -467,8 +467,7 @@ def repl(m):
467467

468468
# ------------------ VICTORIA.md via SSH ------------------
469469
def ensure_victoria_md() -> bool:
470-
root = Path.cwd()
471-
target = root / VICTORIA_FILE
470+
target = APP_HOME / VICTORIA_FILE
472471
if target.exists():
473472
return True
474473

@@ -499,10 +498,10 @@ def ensure_victoria_md() -> bool:
499498

500499
shutil.copy2(src, target)
501500
size = target.stat().st_size
502-
501+
503502
success_animation(f"{VICTORIA_FILE} successfully acquired!")
504503
print(f"{T.CYAN}{T.CHART} File size: {T.WHITE}{size:,} bytes{T.NC}")
505-
print(f"{T.CYAN}{T.MAP} Location: {T.WHITE}./{VICTORIA_FILE}{T.NC}")
504+
print(f"{T.CYAN}{T.MAP} Location: {T.WHITE}{target}{T.NC}")
506505

507506
# Preview
508507
print(f"\n{T.MAGENTA}{T.BOOK} DOCUMENT PREVIEW{T.NC}")
@@ -525,10 +524,10 @@ def ensure_victoria_md() -> bool:
525524

526525
def prompt_update_victoria():
527526
section_header("KNOWLEDGE BASE STATUS", T.BOOK)
528-
529-
target = Path(VICTORIA_FILE)
527+
528+
target = APP_HOME / VICTORIA_FILE
530529
if target.exists():
531-
info(f"{VICTORIA_FILE} already exists in current directory")
530+
info(f"{VICTORIA_FILE} already exists in {APP_HOME}")
532531
print("\nUpdate options:")
533532
print(f" {T.GREEN}[Y]{T.NC} Update to latest from private repo")
534533
print(f" {T.YELLOW}[N]{T.NC} Use existing local copy (default)")
@@ -538,7 +537,7 @@ def prompt_update_victoria():
538537
else:
539538
good(f"Using existing {VICTORIA_FILE}")
540539
else:
541-
warn(f"{VICTORIA_FILE} not found in current directory")
540+
warn(f"{VICTORIA_FILE} not found in {APP_HOME}")
542541
print("\nDownload options:")
543542
print(f" {T.GREEN}[Y]{T.NC} Download via SSH (recommended)")
544543
print(f" {T.YELLOW}[N]{T.NC} Skip download and continue")
@@ -553,15 +552,17 @@ def snowflake_env_missing() -> List[str]:
553552
return [v for v in SNOWFLAKE_ENV_VARS if not os.environ.get(v)]
554553

555554
def load_base_template() -> Dict[str, Any]:
556-
path = APP_HOME / CONFIG_TEMPLATE
555+
path_home = APP_HOME / CONFIG_TEMPLATE
556+
path = path_home if path_home.exists() else resource_path(CONFIG_TEMPLATE)
557557
if not path.exists():
558-
raise FileNotFoundError(f"Missing {CONFIG_TEMPLATE} in {APP_HOME}")
558+
raise FileNotFoundError(f"Missing {CONFIG_TEMPLATE}")
559559
return read_json(path)
560560

561561
def load_snowflake_fragment() -> Dict[str, Any]:
562-
path = APP_HOME / SNOWFLAKE_FRAG
562+
path_home = APP_HOME / SNOWFLAKE_FRAG
563+
path = path_home if path_home.exists() else resource_path(SNOWFLAKE_FRAG)
563564
if not path.exists():
564-
raise FileNotFoundError(f"Missing {SNOWFLAKE_FRAG} in {APP_HOME}")
565+
raise FileNotFoundError(f"Missing {SNOWFLAKE_FRAG}")
565566
return read_json(path)
566567

567568
def build_config(include_snowflake: bool, strict_env: bool) -> Dict[str, Any]:

0 commit comments

Comments
 (0)