@@ -45,90 +45,8 @@ def clone_product(product: str) -> None:
4545 print (f"Repository { product } already exists, skipping clone" )
4646
4747
48- def clone_and_init_products () -> None :
49- """Clone all products from GitHub if they don't exist."""
50- for product in PRODUCTS :
51- clone_product (product )
52- init_product (product )
53-
54-
55- def init () -> None :
56- """Set up waypoint, install dependencies."""
57- clone_and_init_products ()
58-
59- if not os .path .exists (os .path .join (WAYPOINT_DIR , "secrets" )):
60- print ("No secrets found. Skipping..." )
61- return
62-
63- for secret_file in os .listdir (os .path .join (WAYPOINT_DIR , "secrets" )):
64- if os .path .isfile (os .path .join (WAYPOINT_DIR , "secrets" , secret_file )):
65- print (f"Loading secrets from: { secret_file } " )
66- with open (
67- os .path .join (WAYPOINT_DIR , "secrets" , secret_file ),
68- "r" ,
69- encoding = "utf-8" ,
70- ) as f :
71- secret_value = f .read ().strip ()
72- os .environ [secret_file ] = secret_value
73- if secret_file not in os .environ :
74- print (f"Error: Secret '{ secret_file } ' not found" )
75- sys .exit (1 )
76- print ("Secrets loaded successfully" )
77-
78-
79- def sync_env (product : str ) -> None :
80- """Sync .env file from product to waypoint."""
81- if product not in PRODUCTS :
82- print (f"Error: Unknown product '{ product } '" )
83- print (f"Available products: { ', ' .join (PRODUCTS .keys ())} " )
84- sys .exit (1 )
85-
86- product_backend_path = os .path .join (CODE_DIR , product , "backend" )
87- waypoint_product_path = os .path .join (WAYPOINT_DIR , product )
88-
89- if not os .path .exists (product_backend_path ):
90- print (f"Error: Backend directory not found at { product_backend_path } " )
91- sys .exit (1 )
92-
93- os .makedirs (waypoint_product_path , exist_ok = True )
94-
95- try :
96- for file in ["Pipfile" , "Pipfile.lock" ]:
97- src = os .path .join (product_backend_path , file )
98- dst = os .path .join (waypoint_product_path , file )
99-
100- if not os .path .exists (src ):
101- print (f"Warning: { file } not found in { product_backend_path } " )
102- continue
103-
104- with open (src , "r" , encoding = "utf-8" ) as f_src :
105- with open (dst , "w" , encoding = "utf-8" ) as f_dst :
106- f_dst .write (f_src .read ())
107- print (f"Copied { file } from { product_backend_path } to { waypoint_product_path } " )
108-
109- venv_path = os .path .join (waypoint_product_path , "venv" )
110- if not os .path .exists (venv_path ):
111- subprocess .run (
112- ["uv" , "venv" , venv_path , "--python" , "3.11" , "--prompt" , product ],
113- check = True ,
114- )
115-
116- subprocess .run (
117- f"cd { waypoint_product_path } && . venv/bin/activate && "
118- f"pipenv requirements --dev > requirements.txt && "
119- f"uv pip install -r requirements.txt" ,
120- shell = True ,
121- check = True ,
122- )
123- print (f"Successfully synced environment for { product } " )
124-
125- except (OSError , subprocess .CalledProcessError ) as e :
126- print (f"Error syncing environment for { product } : { str (e )} " )
127- sys .exit (1 )
128-
129-
130- def init_product (product : str ) -> None :
131- """Initialize a product environment"""
48+ def clone_and_init_product (product : str ) -> None :
49+ """Clone and initialize a product environment."""
13250 if product == "ohq" :
13351 product = "office-hours-queue"
13452
@@ -217,6 +135,87 @@ def init_product(product: str) -> None:
217135 print (f"Product '{ product } ' initialized successfully." )
218136
219137
138+ def clone_and_init_products () -> None :
139+ """Clone all products from GitHub if they don't exist and init their product environments."""
140+ for product in PRODUCTS :
141+ clone_and_init_product (product )
142+
143+
144+ def init () -> None :
145+ """Set up waypoint, install dependencies."""
146+ clone_and_init_products ()
147+
148+ if not os .path .exists (os .path .join (WAYPOINT_DIR , "secrets" )):
149+ print ("No secrets found. Skipping..." )
150+ return
151+
152+ for secret_file in os .listdir (os .path .join (WAYPOINT_DIR , "secrets" )):
153+ if os .path .isfile (os .path .join (WAYPOINT_DIR , "secrets" , secret_file )):
154+ print (f"Loading secrets from: { secret_file } " )
155+ with open (
156+ os .path .join (WAYPOINT_DIR , "secrets" , secret_file ),
157+ "r" ,
158+ encoding = "utf-8" ,
159+ ) as f :
160+ secret_value = f .read ().strip ()
161+ os .environ [secret_file ] = secret_value
162+ if secret_file not in os .environ :
163+ print (f"Error: Secret '{ secret_file } ' not found" )
164+ sys .exit (1 )
165+ print ("Secrets loaded successfully" )
166+
167+
168+ def sync_env (product : str ) -> None :
169+ """Sync .env file from product to waypoint."""
170+ if product not in PRODUCTS :
171+ print (f"Error: Unknown product '{ product } '" )
172+ print (f"Available products: { ', ' .join (PRODUCTS .keys ())} " )
173+ sys .exit (1 )
174+
175+ product_backend_path = os .path .join (CODE_DIR , product , "backend" )
176+ waypoint_product_path = os .path .join (WAYPOINT_DIR , product )
177+
178+ if not os .path .exists (product_backend_path ):
179+ print (f"Error: Backend directory not found at { product_backend_path } " )
180+ sys .exit (1 )
181+
182+ os .makedirs (waypoint_product_path , exist_ok = True )
183+
184+ try :
185+ for file in ["Pipfile" , "Pipfile.lock" ]:
186+ src = os .path .join (product_backend_path , file )
187+ dst = os .path .join (waypoint_product_path , file )
188+
189+ if not os .path .exists (src ):
190+ print (f"Warning: { file } not found in { product_backend_path } " )
191+ continue
192+
193+ with open (src , "r" , encoding = "utf-8" ) as f_src :
194+ with open (dst , "w" , encoding = "utf-8" ) as f_dst :
195+ f_dst .write (f_src .read ())
196+ print (f"Copied { file } from { product_backend_path } to { waypoint_product_path } " )
197+
198+ venv_path = os .path .join (waypoint_product_path , "venv" )
199+ if not os .path .exists (venv_path ):
200+ subprocess .run (
201+ ["uv" , "venv" , venv_path , "--python" , "3.11" , "--prompt" , product ],
202+ check = True ,
203+ )
204+
205+ subprocess .run (
206+ f"cd { waypoint_product_path } && . venv/bin/activate && "
207+ f"pipenv requirements --dev > requirements.txt && "
208+ f"uv pip install -r requirements.txt" ,
209+ shell = True ,
210+ check = True ,
211+ )
212+ print (f"Successfully synced environment for { product } " )
213+
214+ except (OSError , subprocess .CalledProcessError ) as e :
215+ print (f"Error syncing environment for { product } : { str (e )} " )
216+ sys .exit (1 )
217+
218+
220219def switch_product (product : str , no_vsc : bool ) -> None :
221220 """Switch to a different product environment"""
222221 if product not in PRODUCTS :
@@ -380,7 +379,7 @@ def main() -> None:
380379 start_services (args .mode )
381380 elif args .command == "init" :
382381 if args .product :
383- init_product (args .product )
382+ clone_and_init_product (args .product )
384383 else :
385384 init ()
386385 elif args .command == "backend" :
0 commit comments