3535SNOWFLAKE_FRAG = "snowflake.mcp.json"
3636OUTPUT_CONFIG = os .environ .get ("VICTORIA_OUTPUT" , f"{ TOOL_CMD } .json" )
3737
38+ APP_HOME = Path .home () / "Victoria"
39+ APP_HOME .mkdir (exist_ok = True )
40+
41+ def resource_path (name : str ) -> Path :
42+ base = Path (getattr (sys , "_MEIPASS" , Path (__file__ ).resolve ().parent ))
43+ return base / name
44+
45+ def ensure_default_files ():
46+ for fname in [CONFIG_TEMPLATE , SNOWFLAKE_FRAG , ".crushignore" ]:
47+ src = resource_path (fname )
48+ dst = APP_HOME / fname
49+ if src .exists () and not dst .exists ():
50+ shutil .copy (src , dst )
51+
3852SNOWFLAKE_ENV_VARS = [
3953 "SNOWFLAKE_ACCOUNT" ,
4054 "SNOWFLAKE_USER" ,
@@ -538,15 +552,15 @@ def snowflake_env_missing() -> List[str]:
538552 return [v for v in SNOWFLAKE_ENV_VARS if not os .environ .get (v )]
539553
540554def load_base_template () -> Dict [str , Any ]:
541- path = Path ( CONFIG_TEMPLATE )
555+ path = APP_HOME / CONFIG_TEMPLATE
542556 if not path .exists ():
543- raise FileNotFoundError (f"Missing { CONFIG_TEMPLATE } " )
557+ raise FileNotFoundError (f"Missing { CONFIG_TEMPLATE } in { APP_HOME } " )
544558 return read_json (path )
545559
546560def load_snowflake_fragment () -> Dict [str , Any ]:
547- path = Path ( SNOWFLAKE_FRAG )
561+ path = APP_HOME / SNOWFLAKE_FRAG
548562 if not path .exists ():
549- raise FileNotFoundError (f"Missing { SNOWFLAKE_FRAG } " )
563+ raise FileNotFoundError (f"Missing { SNOWFLAKE_FRAG } in { APP_HOME } " )
550564 return read_json (path )
551565
552566def build_config (include_snowflake : bool , strict_env : bool ) -> Dict [str , Any ]:
@@ -564,8 +578,9 @@ def generate_config(include_snowflake: bool) -> bool:
564578 try :
565579 ship_loading_animation ("Generating navigation configuration" , 2.0 )
566580 cfg = build_config (include_snowflake , strict_env = include_snowflake )
567- write_json (Path (OUTPUT_CONFIG ), cfg )
568- success_animation (f"Configuration written to { OUTPUT_CONFIG } " )
581+ out_path = APP_HOME / OUTPUT_CONFIG
582+ write_json (out_path , cfg )
583+ success_animation (f"Configuration written to { out_path } " )
569584 return True
570585 except Exception as ex :
571586 err (f"Configuration generation failed: { ex } " )
@@ -612,13 +627,14 @@ def launch_tool():
612627 print (f"\n { T .GREEN } { T .TARGET } Launching Victoria Data Navigator{ T .NC } " )
613628
614629 try :
630+ cmd = [TOOL_CMD , "-y" , "-c" , str (APP_HOME )]
615631 if os .name == "nt" :
616- proc = subprocess .run ([ TOOL_CMD ] )
632+ proc = subprocess .run (cmd )
617633 if proc .returncode != 0 :
618634 err (f"{ TOOL_CMD } exited with error code { proc .returncode } " )
619635 sys .exit (proc .returncode )
620636 else :
621- os .execvp (TOOL_CMD , [ TOOL_CMD ] )
637+ os .execvp (TOOL_CMD , cmd )
622638 except FileNotFoundError :
623639 err (f"'{ TOOL_CMD } ' command not found in PATH" )
624640 sys .exit (1 )
@@ -659,7 +675,7 @@ def course_menu() -> str:
659675# ------------------ Main ------------------
660676def remove_local_duckdb ():
661677 """Remove local DuckDB file to ensure a clean start."""
662- db_path = Path ( "data" ) / "adtech.duckdb"
678+ db_path = APP_HOME / "adtech.duckdb"
663679 try :
664680 if db_path .exists ():
665681 db_path .unlink ()
@@ -670,6 +686,7 @@ def remove_local_duckdb():
670686 warn (f"Could not remove { db_path } : { e } " )
671687
672688def main ():
689+ ensure_default_files ()
673690 clear_screen ()
674691 banner ()
675692 remove_local_duckdb ()
0 commit comments