Release v0.2.0 with Docker deployment

This commit is contained in:
Formsmith
2026-06-20 10:07:33 +03:00
parent 2d0ed7ef23
commit 57361a3b2a
13 changed files with 669 additions and 140 deletions
+26
View File
@@ -0,0 +1,26 @@
.git
.github
.codex
.codex-remote-attachments
node_modules
**/node_modules
**/.next
**/out
build
dist
coverage
test-results
playwright-report
.playwright-cli
.env
.env*.local
*.log
*.tsbuildinfo
.DS_Store
Thumbs.db
.idea
.vscode
+26
View File
@@ -0,0 +1,26 @@
# syntax=docker/dockerfile:1
FROM node:22-alpine AS builder
WORKDIR /app
ENV NEXT_TELEMETRY_DISABLED=1
ENV STATIC_EXPORT=true
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM nginx:stable-alpine AS runner
COPY deploy/nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/apps/web/out /usr/share/nginx/html
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD wget -q -O - http://127.0.0.1/healthz | grep -q '^ok$' || exit 1
CMD ["nginx", "-g", "daemon off;"]
+78
View File
@@ -18,6 +18,7 @@
<a href="LICENSE"><img alt="MIT license" src="https://img.shields.io/badge/license-MIT-16a34a"></a>
<a href="https://github.com/Formsmith746/SketchForge-3D/stargazers"><img alt="GitHub stars" src="https://img.shields.io/github/stars/Formsmith746/SketchForge-3D?style=social"></a>
<img alt="Local first" src="https://img.shields.io/badge/local--first-no%20account-0ea5e9">
<img alt="Version 0.2.0" src="https://img.shields.io/badge/version-0.2.0-2563eb">
</p>
</div>
@@ -64,6 +65,83 @@ Open:
http://127.0.0.1:3000/
```
## Docker / FabLab Server (Recommended)
The Docker image contains a static SketchForge build served by Nginx. Projects stay in each user's browser; STL and OBJ files download through that browser. The container does not receive or store project files.
Docker is the recommended server setup because it packages the correct Node build environment, static app, Nginx configuration, health check, and restart policy together. It is easier to reproduce and update than configuring each part by hand.
Requirements:
- Docker Engine with Docker Compose
Build and start SketchForge:
```bash
docker compose up --build -d
```
Open it on the server:
```text
http://127.0.0.1:3000/
```
Other computers on the same network can use the server's LAN address:
```text
http://SERVER_IP:3000/
```
To use another host port:
```bash
SKETCHFORGE_PORT=8080 docker compose up --build -d
```
On PowerShell:
```powershell
$env:SKETCHFORGE_PORT = "8080"
docker compose up --build -d
```
Stop the server with:
```bash
docker compose down
```
### Manual Static Deployment (Advanced)
This is the harder alternative for servers where Docker cannot be used. The administrator must install and maintain Node.js, npm, Nginx or another static web server, firewall access, startup behavior, and future updates separately.
Requirements:
- Node.js 20 or newer
- npm
- Nginx, Apache, Caddy, or another static web server
Create the static build on Linux or macOS:
```bash
npm ci
STATIC_EXPORT=true npm run build
```
Create it with PowerShell on Windows:
```powershell
npm ci
$env:STATIC_EXPORT = "true"
npm run build
Remove-Item Env:STATIC_EXPORT
```
The deployable files are generated in `apps/web/out`. Configure the web server to serve that directory and fall back to `index.html` for unknown application paths. [`deploy/nginx.conf`](deploy/nginx.conf) is the configuration used by the Docker image and can be adapted for a manual Nginx installation.
The administrator must also open the chosen LAN port in the server firewall and arrange for the web server to start automatically after a reboot. For each SketchForge update, pull the new source, install dependencies, rebuild `apps/web/out`, replace the served files, and reload the web server.
## Development
```bash
+198 -16
View File
@@ -413,7 +413,7 @@ button {
grid-row: 1 / span 2;
}
.project-delete {
.project-menu-trigger {
position: absolute;
top: 12px;
right: 12px;
@@ -430,15 +430,59 @@ button {
box-shadow: 0 2px 6px rgba(24, 43, 60, 0.1);
}
.project-card:hover .project-delete,
.project-delete:focus-visible {
.project-card:hover .project-menu-trigger,
.project-menu-trigger:focus-visible {
opacity: 1;
}
.project-delete:hover {
.project-menu-trigger:hover,
.project-menu-trigger[aria-expanded="true"] {
color: #264d6b;
border-color: #a9bdcc;
background: #f5f9fc;
}
.project-card-menu {
position: absolute;
top: 52px;
right: 12px;
z-index: 4;
display: grid;
width: 148px;
gap: 3px;
padding: 5px;
color: #314b61;
background: #ffffff;
border: 1px solid #ccd9e3;
border-radius: 7px;
box-shadow: 0 10px 28px rgba(24, 43, 60, 0.18);
}
.project-card-menu button {
display: flex;
align-items: center;
gap: 9px;
min-height: 36px;
padding: 0 10px;
color: inherit;
background: transparent;
border-radius: 5px;
font-weight: 700;
text-align: left;
}
.project-card-menu button:hover,
.project-card-menu button:focus-visible {
background: #eef5fa;
}
.project-card-menu button.delete {
color: #b01925;
border-color: #efb7be;
background: #fff4f5;
}
.project-card-menu button.delete:hover,
.project-card-menu button.delete:focus-visible {
background: #fff1f2;
}
.dashboard-confirm-overlay {
@@ -524,6 +568,44 @@ button {
background: #c82031;
}
.dashboard-confirm-save {
color: #ffffff;
border: 1px solid #147ca8;
background: #147ca8;
}
.dashboard-confirm-save:disabled {
cursor: not-allowed;
opacity: 0.45;
}
.dashboard-rename-dialog > label {
display: grid;
gap: 7px;
padding: 18px;
color: #40586c;
font-size: 13px;
font-weight: 800;
}
.dashboard-rename-dialog input {
width: 100%;
height: 42px;
padding: 0 12px;
color: #1d3448;
background: #ffffff;
border: 1px solid #b9cad7;
border-radius: 6px;
font: inherit;
font-weight: 600;
outline: none;
}
.dashboard-rename-dialog input:focus {
border-color: #1486b5;
box-shadow: 0 0 0 3px rgba(20, 134, 181, 0.14);
}
.project-empty {
display: grid;
min-height: 190px;
@@ -2707,9 +2789,9 @@ button {
.workspace-modal-card {
position: relative;
z-index: 2;
width: 520px;
width: 760px;
max-width: calc(100vw - 32px);
min-height: min(720px, calc(100vh - 104px));
height: min(650px, calc(100vh - 104px));
max-height: calc(100vh - 104px);
overflow: hidden;
color: #264158;
@@ -2753,14 +2835,86 @@ button {
cursor: pointer;
}
.workspace-modal-layout {
display: grid;
grid-template-columns: 190px minmax(0, 1fr);
height: calc(100% - 55px);
min-height: 0;
}
.workspace-settings-nav {
display: grid;
align-content: start;
gap: 6px;
padding: 16px 10px;
background: #f4f7f9;
border-right: 1px solid #d8e1e8;
}
.workspace-settings-nav button {
display: flex;
align-items: center;
gap: 10px;
width: 100%;
min-height: 42px;
padding: 0 12px;
color: #526b7e;
background: transparent;
border: 1px solid transparent;
border-radius: 5px;
cursor: pointer;
font-size: 13px;
font-weight: 800;
text-align: left;
}
.workspace-settings-nav button:hover {
color: #274861;
background: #e9f0f4;
}
.workspace-settings-nav button.active {
color: #176f95;
background: #ffffff;
border-color: #c7d9e4;
box-shadow: 0 1px 3px rgba(31, 64, 84, 0.08);
}
.workspace-modal-content {
display: grid;
grid-template-rows: minmax(0, 1fr) auto;
min-width: 0;
min-height: 0;
overflow: hidden;
}
.workspace-modal-body {
display: grid;
align-content: start;
gap: 20px;
max-height: calc(100vh - 159px);
padding: 18px 18px 22px;
min-height: 0;
padding: 22px 24px;
overflow: auto;
}
.workspace-section-heading {
display: grid;
gap: 5px;
padding-bottom: 15px;
border-bottom: 1px solid #e2e9ee;
}
.workspace-section-heading strong {
color: #213d54;
font-size: 17px;
}
.workspace-section-heading span {
color: #718697;
font-size: 12px;
font-weight: 650;
}
.workspace-row,
.workspace-toggle,
.workspace-select {
@@ -2858,7 +3012,9 @@ button {
}
.make-default-button {
height: 30px;
min-width: 128px;
height: 34px;
padding: 0 14px;
color: #264158;
background: #f7fafc;
border: 1px solid #d6e0e8;
@@ -2868,9 +3024,18 @@ button {
font-weight: 800;
}
.make-default-button {
width: 240px;
margin-left: 153px;
.workspace-modal-footer {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
min-height: 64px;
padding: 12px 24px;
color: #718697;
background: #fbfcfd;
border-top: 1px solid #dfe7ed;
font-size: 12px;
font-weight: 700;
}
.workspace-modal-header button:hover,
@@ -3333,11 +3498,28 @@ button {
}
.workspace-modal-card {
width: min(520px, calc(100vw - 24px));
min-height: calc(100vh - 112px);
width: min(760px, calc(100vw - 24px));
height: calc(100vh - 112px);
max-height: calc(100vh - 112px);
}
.workspace-modal-layout {
grid-template-columns: 165px minmax(0, 1fr);
}
.workspace-settings-nav {
padding-inline: 8px;
}
.workspace-settings-nav button {
padding-inline: 9px;
}
.workspace-modal-body,
.workspace-modal-footer {
padding-inline: 18px;
}
.workplane-plane {
inset: 0;
}
+100 -3
View File
@@ -1,6 +1,6 @@
"use client";
import { Clock3, FileUp, Grid3X3, HomeIcon, List, Plus, Search, Settings, SlidersHorizontal, Trash2, X } from "lucide-react";
import { Clock3, EllipsisVertical, FileUp, Grid3X3, HomeIcon, List, Pencil, Plus, Search, Settings, SlidersHorizontal, Trash2, X } from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { SketchForgeEditor, importedShapeFromStl } from "@/components/SketchForgeEditor";
import { createLocalId } from "@/lib/localIds";
@@ -574,6 +574,14 @@ export default function Home() {
});
};
const renameProject = (projectId: string, name: string) => {
const nextName = name.trim().slice(0, 80);
if (!nextName) return;
setProjects((current) =>
current.map((project) => (project.id === projectId ? { ...project, name: nextName, updatedAt: Date.now() } : project)),
);
};
if (!mounted) {
return null;
}
@@ -629,6 +637,7 @@ export default function Home() {
onOpenProject={openEditor}
onOpenSettings={() => setSettingsOpen(true)}
onQueryChange={setQuery}
onRenameProject={renameProject}
onSortModeChange={setSortMode}
onViewModeChange={setViewMode}
onWorkspace={openLatestProject}
@@ -645,6 +654,7 @@ export default function Home() {
onProjectSnapshot={updateProjectSnapshot}
onProjectWorkspaceChange={updateProjectWorkspace}
projectId={activeProjectId}
projectName={activeProject?.name}
projectRevision={activeProjectShapeEntry?.revision ?? activeProject?.revision ?? 0}
/>
</div>
@@ -672,6 +682,7 @@ function Dashboard({
onOpenProject,
onOpenSettings,
onQueryChange,
onRenameProject,
onSortModeChange,
onViewModeChange,
onWorkspace,
@@ -694,12 +705,17 @@ function Dashboard({
onOpenProject: (projectId: string) => void;
onOpenSettings: () => void;
onQueryChange: (value: string) => void;
onRenameProject: (projectId: string, name: string) => void;
onSortModeChange: (value: string) => void;
onViewModeChange: (value: ViewMode) => void;
onWorkspace: () => void;
}) {
const [openProjectMenuId, setOpenProjectMenuId] = useState<string | null>(null);
const [projectPendingDeleteId, setProjectPendingDeleteId] = useState<string | null>(null);
const [projectPendingRenameId, setProjectPendingRenameId] = useState<string | null>(null);
const [projectNameDraft, setProjectNameDraft] = useState("");
const projectPendingDelete = projects.find((project) => project.id === projectPendingDeleteId) ?? null;
const projectPendingRename = projects.find((project) => project.id === projectPendingRenameId) ?? null;
useEffect(() => {
if (!projectPendingDeleteId) return;
@@ -713,6 +729,23 @@ function Dashboard({
setProjectPendingDeleteId(null);
};
const startProjectRename = (project: DashboardProject) => {
setOpenProjectMenuId(null);
setProjectPendingRenameId(project.id);
setProjectNameDraft(project.name);
};
const closeProjectRename = () => {
setProjectPendingRenameId(null);
setProjectNameDraft("");
};
const confirmProjectRename = () => {
if (!projectPendingRename || !projectNameDraft.trim()) return;
onRenameProject(projectPendingRename.id, projectNameDraft);
closeProjectRename();
};
return (
<main className="dashboard-shell">
<header className="dashboard-topbar">
@@ -806,9 +839,36 @@ function Dashboard({
{formatUpdated(project.updatedAt)} - {project.shapes} shapes
</span>
</button>
<button className="project-delete" type="button" aria-label={`Delete ${project.name}`} title="Delete project" onClick={() => setProjectPendingDeleteId(project.id)}>
<Trash2 size={17} strokeWidth={2.4} />
<button
className="project-menu-trigger"
type="button"
aria-label={`Project options for ${project.name}`}
aria-expanded={openProjectMenuId === project.id}
title="Project options"
onClick={() => setOpenProjectMenuId((current) => (current === project.id ? null : project.id))}
>
<EllipsisVertical size={19} strokeWidth={2.5} />
</button>
{openProjectMenuId === project.id ? (
<div className="project-card-menu" role="menu" aria-label={`Options for ${project.name}`}>
<button type="button" role="menuitem" onClick={() => startProjectRename(project)}>
<Pencil size={16} />
<span>Rename</span>
</button>
<button
className="delete"
type="button"
role="menuitem"
onClick={() => {
setOpenProjectMenuId(null);
setProjectPendingDeleteId(project.id);
}}
>
<Trash2 size={16} />
<span>Delete</span>
</button>
</div>
) : null}
</article>
))}
</div>
@@ -845,6 +905,43 @@ function Dashboard({
</section>
) : null}
{projectPendingRename ? (
<section className="dashboard-confirm-overlay" role="dialog" aria-modal="true" aria-labelledby="rename-project-title">
<form
className="dashboard-confirm-dialog dashboard-rename-dialog"
onSubmit={(event) => {
event.preventDefault();
confirmProjectRename();
}}
>
<header>
<strong id="rename-project-title">Rename project</strong>
<button type="button" aria-label="Cancel project rename" onClick={closeProjectRename}>
<X size={18} />
</button>
</header>
<label>
<span>Project name</span>
<input
autoFocus
maxLength={80}
value={projectNameDraft}
onChange={(event) => setProjectNameDraft(event.currentTarget.value)}
aria-label="Project name"
/>
</label>
<div className="dashboard-confirm-actions">
<button className="dashboard-confirm-cancel" type="button" onClick={closeProjectRename}>
Cancel
</button>
<button className="dashboard-confirm-save" type="submit" disabled={!projectNameDraft.trim()}>
Save
</button>
</div>
</form>
</section>
) : null}
{settingsOpen ? (
<section className="dashboard-settings-panel" role="dialog" aria-modal="true" aria-label="Download settings">
<header>
@@ -56,6 +56,7 @@ import {
workplaneShapesEqual,
} from "@/lib/workplaneShapes";
import { createLocalId } from "@/lib/localIds";
import { projectExportFileName } from "@/lib/exportNames";
import { makeShapeFromAsset, sceneShape, toolbarShapeAssets, type ToolbarShapeAsset } from "@/lib/shapeCatalog";
import { importedShapeFromStl, importExtensionSupported } from "@/lib/stlImport";
import type { AlignAxis, AlignHandleStatus, AlignTarget, GridSize, ShapeAsset, WorkplaneShape, WorkplaneWorkspaceSettings } from "@/types/sketchforge";
@@ -4006,6 +4007,7 @@ export function SketchForgeEditor({
onProjectSnapshot,
onProjectWorkspaceChange,
projectId,
projectName = "SketchForge design",
projectRevision = 0,
}: {
initialShapes?: WorkplaneShape[];
@@ -4016,6 +4018,7 @@ export function SketchForgeEditor({
onProjectSnapshot?: (snapshot: { image: string; projectId: string; shapes: number }) => void;
onProjectWorkspaceChange?: (snapshot: { projectId: string; workspace: WorkplaneWorkspaceSettings; snap: GridSize }) => void;
projectId?: string | null;
projectName?: string;
projectRevision?: number;
} = {}) {
const [shapes, setShapes] = useState<WorkplaneShape[]>(() => initialShapes.map(canonicalizeShape));
@@ -4983,7 +4986,6 @@ export function SketchForgeEditor({
return;
}
const meshes = exportable.map(meshForShape);
const scope = hasSelection ? "selection" : "design";
const selectedNotice = `Exported ${exportable.length} selected shape${exportable.length === 1 ? "" : "s"}`;
const finishNotice = (label: string, result: DownloadResult) => {
if (result.mode === "folder") {
@@ -4996,15 +4998,15 @@ export function SketchForgeEditor({
setNotice(error instanceof Error ? error.message : `Could not export ${label}`);
};
if (format === "stl") {
void downloadTextFile(`sketchforge-${scope}.stl`, toStl(meshes), "model/stl")
void downloadTextFile(projectExportFileName(projectName, "stl"), toStl(meshes), "model/stl")
.then((result) => finishNotice("STL", result))
.catch((error: unknown) => failNotice("STL", error));
return;
}
void downloadTextFile(`sketchforge-${scope}.obj`, toObj(meshes), "text/plain")
void downloadTextFile(projectExportFileName(projectName, "obj"), toObj(meshes), "text/plain")
.then((result) => finishNotice("OBJ", result))
.catch((error: unknown) => failNotice("OBJ", error));
}, [hasSelection, selectedShapes, shapes]);
}, [hasSelection, projectName, selectedShapes, shapes]);
const clearDesign = useCallback(() => {
commitShapes([], [], "New empty design");
@@ -1,11 +1,12 @@
"use client";
import { X } from "lucide-react";
import { Grid3X3, Palette, Ruler, X } from "lucide-react";
import { useState, type CSSProperties } from "react";
import { DEFAULT_WORKPLANE_WORKSPACE } from "@/lib/workplaneSettings";
import type { GridSize, WorkplaneWorkspaceSettings } from "@/types/sketchforge";
type WorkspaceSettings = WorkplaneWorkspaceSettings;
type WorkspaceSettingsSection = "appearance" | "measurement" | "workplane";
const GRID_SIZES: GridSize[] = ["Off", "0.1 mm", "0.25 mm", "0.5 mm", "1.0 mm", "2.0 mm", "5.0 mm", "Brick"];
const MIN_WORKSPACE_SIZE = 60;
@@ -49,6 +50,7 @@ export function WorkspaceSettingsModal({
onClose: () => void;
}) {
const [defaultSaved, setDefaultSaved] = useState(false);
const [activeSection, setActiveSection] = useState<WorkspaceSettingsSection>("appearance");
const patchWorkspace = (patch: Partial<WorkspaceSettings>) => {
setDefaultSaved(false);
onWorkspaceChange({ ...workspace, ...patch });
@@ -83,7 +85,30 @@ export function WorkspaceSettingsModal({
</button>
</header>
<div className="workspace-modal-layout">
<nav className="workspace-settings-nav" aria-label="Workspace settings sections">
<button className={activeSection === "appearance" ? "active" : ""} aria-current={activeSection === "appearance" ? "page" : undefined} onClick={() => setActiveSection("appearance")}>
<Palette size={18} />
<span>Appearance</span>
</button>
<button className={activeSection === "measurement" ? "active" : ""} aria-current={activeSection === "measurement" ? "page" : undefined} onClick={() => setActiveSection("measurement")}>
<Ruler size={18} />
<span>Measurement</span>
</button>
<button className={activeSection === "workplane" ? "active" : ""} aria-current={activeSection === "workplane" ? "page" : undefined} onClick={() => setActiveSection("workplane")}>
<Grid3X3 size={18} />
<span>Workplane</span>
</button>
</nav>
<div className="workspace-modal-content">
<div className="workspace-modal-body">
{activeSection === "appearance" ? (
<>
<div className="workspace-section-heading">
<strong>Appearance</strong>
<span>Adjust the canvas and navigation behavior.</span>
</div>
<div className="workspace-row">
<span>Background color</span>
<button
@@ -100,7 +125,6 @@ export function WorkspaceSettingsModal({
checked={workspace.cruiseShapes}
onChange={(cruiseShapes) => patchWorkspace({ cruiseShapes })}
/>
<label className="workspace-range">
<span>Zoom speed</span>
<input
@@ -115,7 +139,15 @@ export function WorkspaceSettingsModal({
<span>Fast</span>
</small>
</label>
</>
) : null}
{activeSection === "measurement" ? (
<>
<div className="workspace-section-heading">
<strong>Measurement</strong>
<span>Choose units, precision, scale, and snapping.</span>
</div>
<WorkspaceSelect
label="Units"
value={workspace.units}
@@ -143,13 +175,21 @@ export function WorkspaceSettingsModal({
onSnapChange(next as GridSize);
}}
/>
</>
) : null}
{activeSection === "workplane" ? (
<>
<div className="workspace-section-heading">
<strong>Workplane</strong>
<span>Set the plate dimensions and visible grid spacing.</span>
</div>
<WorkspaceSelect
label="Workplane size"
value={workspace.sizePreset}
options={WORKSPACE_SIZE_PRESETS.map((preset) => preset.label)}
onChange={setWorkspaceSizePreset}
/>
<div className="workspace-dimensions">
<label>
<span>Width</span>
@@ -190,7 +230,12 @@ export function WorkspaceSettingsModal({
</label>
</div>
) : null}
</>
) : null}
</div>
<div className="workspace-modal-footer">
<span>Save the current settings for this project.</span>
<button
className="make-default-button"
onClick={() => {
@@ -202,6 +247,8 @@ export function WorkspaceSettingsModal({
</button>
</div>
</div>
</div>
</div>
<button className="workspace-modal-backdrop" aria-label="Close settings" onClick={onClose} />
</div>
);
+11
View File
@@ -0,0 +1,11 @@
export type ProjectExportFormat = "stl" | "obj";
export function projectExportFileName(projectName: string, format: ProjectExportFormat) {
const safeProjectName = projectName
.trim()
.replace(/[<>:"/\\|?*\u0000-\u001f]/g, "-")
.replace(/\s+/g, " ")
.replace(/[. ]+$/g, "")
.slice(0, 120);
return `${safeProjectName || "SketchForge design"}.${format}`;
}
+9
View File
@@ -0,0 +1,9 @@
services:
sketchforge:
image: sketchforge:local
build:
context: .
dockerfile: Dockerfile
ports:
- "${SKETCHFORGE_PORT:-3000}:80"
restart: unless-stopped
+32
View File
@@ -0,0 +1,32 @@
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
index index.html;
server_tokens off;
gzip on;
gzip_types application/javascript application/json application/wasm image/svg+xml text/css text/plain;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "same-origin" always;
location = /healthz {
access_log off;
default_type text/plain;
return 200 "ok\n";
}
location /_next/static/ {
try_files $uri =404;
expires 1y;
add_header Cache-Control "public, max-age=31536000, immutable";
}
location / {
try_files $uri $uri/ $uri.html /index.html;
add_header Cache-Control "no-cache";
}
}
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "sketchforge",
"version": "0.1.0",
"version": "0.2.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sketchforge",
"version": "0.1.0",
"version": "0.2.0",
"dependencies": {
"@tailwindcss/postcss": "^4.1.8",
"@types/three": "^0.184.1",
+4 -2
View File
@@ -1,6 +1,6 @@
{
"name": "sketchforge",
"version": "0.1.0",
"version": "0.2.0",
"private": true,
"scripts": {
"dev": "next dev apps/web",
@@ -11,7 +11,9 @@
"test": "vitest run --config tests/vitest.config.ts",
"test:watch": "vitest --config tests/vitest.config.ts",
"perf": "vitest run --config tests/vitest.perf.config.ts --reporter verbose",
"ci": "npm run typecheck && npm run test"
"ci": "npm run typecheck && npm run test",
"docker:build": "docker build -t sketchforge:local .",
"docker:run": "docker run --rm -p 3000:80 sketchforge:local"
},
"dependencies": {
"@tailwindcss/postcss": "^4.1.8",
+17
View File
@@ -0,0 +1,17 @@
import { describe, expect, it } from "vitest";
import { projectExportFileName } from "@/lib/exportNames";
describe("project export filenames", () => {
it("uses the project name for each supported export format", () => {
expect(projectExportFileName("Gearbox Prototype", "stl")).toBe("Gearbox Prototype.stl");
expect(projectExportFileName("Gearbox Prototype", "obj")).toBe("Gearbox Prototype.obj");
});
it("removes filesystem-reserved characters without discarding the project name", () => {
expect(projectExportFileName(' enclosure: v2 / final? ', "stl")).toBe("enclosure- v2 - final-.stl");
});
it("falls back to a useful name when the project name cannot be used", () => {
expect(projectExportFileName("...", "obj")).toBe("SketchForge design.obj");
});
});