Initial project creation panel

This commit is contained in:
Owen Qwen
2026-08-11 15:58:14 +00:00
commit a519e67eac
22 changed files with 7173 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
import os from "node:os";
import path from "node:path";
import { z } from "zod";
export const projectNameSchema = z
.string()
.trim()
.min(1, "Enter a project name.")
.max(64, "Project names must be 64 characters or fewer.")
.regex(
/^[a-zA-Z0-9][a-zA-Z0-9 _-]*$/,
"Use letters, numbers, spaces, hyphens, or underscores.",
)
.refine((name) => !name.includes(".."), "Project names cannot contain '..'.");
export function getProjectsRoot() {
return path.resolve(process.env.PROJECTS_ROOT || path.join(os.homedir(), "projects"));
}
export function getProjectPath(name: string) {
const root = getProjectsRoot();
const projectPath = path.resolve(root, name);
if (projectPath === root || !projectPath.startsWith(`${root}${path.sep}`)) {
throw new Error("The project path must remain inside the projects directory.");
}
return projectPath;
}
+6
View File
@@ -0,0 +1,6 @@
import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}