44import subprocess
55import sys
66
7- PRODUCTS = {
8- "office-hours-queue" : {
9- "node_version" : "22" ,
10- },
11- "penn-clubs" : {
12- "node_version" : "20" ,
13- },
14- "penn-mobile" : {
15- "node_version" : "22" ,
16- },
17- "penn-courses" : {
18- "node_version" : "22" ,
19- },
20- "platform" : {
21- "node_version" : "22" ,
22- },
23- }
7+ PRODUCTS = ["office-hours-queue" , "penn-clubs" , "penn-mobile" , "penn-courses" , "platform" ]
248
259WAYPOINT_DIR = "/opt/waypoint"
2610CODE_DIR = "/labs"
@@ -52,7 +36,7 @@ def clone_and_init_product(product: str) -> None:
5236
5337 if product not in PRODUCTS :
5438 print (f"Error: Unknown product '{ product } '" )
55- print (f"Available products: { ', ' .join (PRODUCTS . keys () )} " )
39+ print (f"Available products: { ', ' .join (PRODUCTS )} " )
5640 sys .exit (1 )
5741
5842 clone_product (product )
@@ -64,18 +48,17 @@ def clone_and_init_product(product: str) -> None:
6448 print (f"Product '{ product } ' is already initialized." )
6549 sys .exit (1 )
6650
67- # Run manage.py commands in product venv
68- venv_path = os .path .join (product_path , "venv" , "bin" , "activate" )
51+ # Run manage.py commands
6952 try :
7053 subprocess .run (
71- f"bash -c 'source { venv_path } && cd { backend_path } && python manage.py migrate'" ,
54+ f"bash -c 'cd { backend_path } && uv run manage.py migrate'" ,
7255 shell = True ,
7356 check = True ,
7457 )
7558
7659 if product not in ["penn-mobile" , "penn-courses" , "platform" ]:
7760 subprocess .run (
78- f"bash -c 'source { venv_path } && cd { backend_path } && python manage.py populate'" ,
61+ f"bash -c 'cd { backend_path } && uv run manage.py populate'" ,
7962 shell = True ,
8063 check = True ,
8164 )
@@ -135,15 +118,10 @@ def clone_and_init_product(product: str) -> None:
135118 print (f"Product '{ product } ' initialized successfully." )
136119
137120
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-
144121def init () -> None :
145122 """Set up waypoint, install dependencies."""
146- clone_and_init_products ()
123+ for product in PRODUCTS :
124+ clone_and_init_product (product )
147125
148126 if not os .path .exists (os .path .join (WAYPOINT_DIR , "secrets" )):
149127 print ("No secrets found. Skipping..." )
@@ -169,7 +147,7 @@ def sync_env(product: str) -> None:
169147 """Sync .env file from product to waypoint."""
170148 if product not in PRODUCTS :
171149 print (f"Error: Unknown product '{ product } '" )
172- print (f"Available products: { ', ' .join (PRODUCTS . keys () )} " )
150+ print (f"Available products: { ', ' .join (PRODUCTS )} " )
173151 sys .exit (1 )
174152
175153 product_backend_path = os .path .join (CODE_DIR , product , "backend" )
@@ -182,7 +160,7 @@ def sync_env(product: str) -> None:
182160 os .makedirs (waypoint_product_path , exist_ok = True )
183161
184162 try :
185- for file in ["Pipfile " , "Pipfile .lock" ]:
163+ for file in ["pyproject.toml " , "uv .lock" ]:
186164 src = os .path .join (product_backend_path , file )
187165 dst = os .path .join (waypoint_product_path , file )
188166
@@ -195,17 +173,8 @@ def sync_env(product: str) -> None:
195173 f_dst .write (f_src .read ())
196174 print (f"Copied { file } from { product_backend_path } to { waypoint_product_path } " )
197175
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-
205176 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" ,
177+ f"cd { waypoint_product_path } && uv sync --frozen --all-groups" ,
209178 shell = True ,
210179 check = True ,
211180 )
@@ -220,7 +189,7 @@ def switch_product(product: str, no_vsc: bool) -> None:
220189 """Switch to a different product environment"""
221190 if product not in PRODUCTS :
222191 print (f"Error: Unknown product '{ product } '" )
223- print (f"Available products: { ', ' .join (PRODUCTS . keys () )} " )
192+ print (f"Available products: { ', ' .join (PRODUCTS )} " )
224193 sys .exit (1 )
225194
226195 product_path = os .path .join (WAYPOINT_DIR , product )
@@ -300,12 +269,15 @@ def start_development(mode: str) -> None:
300269
301270 product_code_path = os .path .join (CODE_DIR , product_name )
302271
272+ backend_start_cmd = f"source { current_link } /.venv/bin/activate && cd { product_code_path } /backend && python manage.py runserver 0.0.0.0:8000"
273+ frontend_start_cmd = f"cd { product_code_path } /frontend && yarn dev"
274+
303275 if mode == "backend" :
304- start_cmd = f"bash -c 'source { current_link } /venv/bin/activate && cd { product_code_path } /backend && python manage.py runserver 0.0.0.0:8000 '"
276+ start_cmd = f"bash -c '{ backend_start_cmd } '"
305277 elif mode == "frontend" :
306- start_cmd = f"bash -c 'cd { product_code_path } /frontend && yarn dev '"
278+ start_cmd = f"bash -c '{ frontend_start_cmd } '"
307279 else :
308- start_cmd = f"bash -c 'source { current_link } /venv/bin/activate && cd { product_code_path } /backend && python manage.py runserver 0.0.0.0:8000 && cd { product_code_path } /frontend && yarn dev '"
280+ start_cmd = f"bash -c '{ backend_start_cmd } && { frontend_start_cmd } '"
309281
310282 try :
311283 subprocess .run (start_cmd , shell = True , check = True )
@@ -324,7 +296,7 @@ def main() -> None:
324296 )
325297 init_parser .add_argument (
326298 "product" ,
327- help = "Product to initalize to, options: " + ", " .join (PRODUCTS . keys () ),
299+ help = "Product to initalize to, options: " + ", " .join (PRODUCTS ),
328300 nargs = "?" ,
329301 default = None ,
330302 )
@@ -334,7 +306,7 @@ def main() -> None:
334306 help = "Switch to a product environment. Starts the uv virtual environment associated with the product and opens the product in VSCode if in a dev container. Use --no-vsc to not open VSCode." ,
335307 )
336308 switch_parser .add_argument (
337- "product" , help = "Product to switch to, options: " + ", " .join (PRODUCTS . keys () )
309+ "product" , help = "Product to switch to, options: " + ", " .join (PRODUCTS )
338310 )
339311 switch_parser .add_argument ("--no-vsc" , action = "store_true" , help = "Do not open VSCode on switch" )
340312
0 commit comments