Update the dev server configuration for a project. Set custom_command to a string to override the auto-detected command. Set custom_command to null/None to clear the custom command and revert to using the auto-detected command. Args: project_name: Name of the project
(
project_name: str,
update: DevServerConfigUpdate,
)
| 378 | |
| 379 | @router.patch("/config", response_model=DevServerConfigResponse) |
| 380 | async def update_devserver_config( |
| 381 | project_name: str, |
| 382 | update: DevServerConfigUpdate, |
| 383 | ) -> DevServerConfigResponse: |
| 384 | """ |
| 385 | Update the dev server configuration for a project. |
| 386 | |
| 387 | Set custom_command to a string to override the auto-detected command. |
| 388 | Set custom_command to null/None to clear the custom command and revert |
| 389 | to using the auto-detected command. |
| 390 | |
| 391 | Args: |
| 392 | project_name: Name of the project |
| 393 | update: Configuration update containing the new custom_command |
| 394 | |
| 395 | Returns: |
| 396 | Updated configuration details for the project's dev server |
| 397 | """ |
| 398 | project_dir = get_project_dir(project_name) |
| 399 | |
| 400 | # Update the custom command |
| 401 | if update.custom_command is None: |
| 402 | # Clear the custom command |
| 403 | try: |
| 404 | clear_dev_command(project_dir) |
| 405 | except ValueError as e: |
| 406 | raise HTTPException(status_code=400, detail=str(e)) |
| 407 | else: |
| 408 | # Strict structural validation first (most specific errors) |
| 409 | try: |
| 410 | validate_custom_command_strict(update.custom_command) |
| 411 | except ValueError as e: |
| 412 | raise HTTPException(status_code=400, detail=str(e)) |
| 413 | |
| 414 | # Then validate against security allowlist |
| 415 | validate_dev_command(update.custom_command, project_dir) |
| 416 | |
| 417 | # Set the custom command |
| 418 | try: |
| 419 | set_dev_command(project_dir, update.custom_command) |
| 420 | except ValueError as e: |
| 421 | raise HTTPException(status_code=400, detail=str(e)) |
| 422 | except OSError as e: |
| 423 | raise HTTPException( |
| 424 | status_code=500, |
| 425 | detail=f"Failed to save configuration: {e}" |
| 426 | ) |
| 427 | |
| 428 | # Return updated config |
| 429 | config = get_project_config(project_dir) |
| 430 | |
| 431 | return DevServerConfigResponse( |
| 432 | detected_type=config["detected_type"], |
| 433 | detected_command=config["detected_command"], |
| 434 | custom_command=config["custom_command"], |
| 435 | effective_command=config["effective_command"], |
| 436 | ) |
nothing calls this directly
no test coverage detected