feat: implement upsert project functionality in sidebar and welcome view

- Refactored project handling in Sidebar and WelcomeView components to use a new `upsertAndSetCurrentProject` action for creating or updating projects.
- Enhanced theme preservation logic during project creation and updates by integrating theme management directly into the store action.
- Cleaned up redundant code related to project existence checks and state updates, improving maintainability and readability.
This commit is contained in:
Cody Seibert
2025-12-12 23:06:22 -05:00
committed by Kacper
parent 7e3f77cb38
commit 6e7352e67e
4 changed files with 105 additions and 72 deletions

View File

@@ -55,6 +55,16 @@ export function createTemplatesRoutes(): Router {
// Build full project path
const projectPath = path.join(parentDir, sanitizedName);
const resolvedParent = path.resolve(parentDir);
const resolvedProject = path.resolve(projectPath);
const relativePath = path.relative(resolvedParent, resolvedProject);
if (relativePath.startsWith("..") || path.isAbsolute(relativePath)) {
return res.status(400).json({
success: false,
error: "Invalid project name; potential path traversal attempt.",
});
}
// Check if directory already exists
try {
await fs.access(projectPath);