Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
feat: add automated desktop release pipeline
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { importExtensionSupported } from "@/lib/stlImport";
|
||||
import { importExtensionSupported } from "@/lib/importExtensions";
|
||||
|
||||
describe("importExtensionSupported", () => {
|
||||
it("accepts STL and SVG imports", () => {
|
||||
it("accepts STL, OBJ, and SVG imports", () => {
|
||||
expect(importExtensionSupported("part.stl")).toBe(true);
|
||||
expect(importExtensionSupported("assembly.obj")).toBe(true);
|
||||
expect(importExtensionSupported("MODEL.OBJ")).toBe(true);
|
||||
expect(importExtensionSupported("logo.svg")).toBe(true);
|
||||
expect(importExtensionSupported("profile.SVG")).toBe(true);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { importedShapeFromObj } from "@/lib/objImport";
|
||||
|
||||
describe("importedShapeFromObj", () => {
|
||||
it("imports triangulated OBJ geometry as a SketchForge mesh", () => {
|
||||
const shape = importedShapeFromObj("panel.obj", [
|
||||
"v 0 0 0",
|
||||
"v 2 0 0",
|
||||
"v 2 3 0",
|
||||
"v 0 3 0",
|
||||
"f 1 2 3 4",
|
||||
].join("\n"));
|
||||
|
||||
expect(shape.name).toBe("panel");
|
||||
expect(shape.kind).toBe("mesh");
|
||||
expect(shape.width).toBe(2);
|
||||
expect(shape.height).toBe(3);
|
||||
expect(shape.depth).toBe(1);
|
||||
expect(shape.importedMesh?.sourceFormat).toBe("obj");
|
||||
expect(shape.importedMesh?.triangleCount).toBe(2);
|
||||
expect(shape.importedMesh?.positions).toHaveLength(18);
|
||||
});
|
||||
|
||||
it("triangulates concave OBJ polygons without filling their cutout", () => {
|
||||
const shape = importedShapeFromObj("concave.obj", [
|
||||
"v 0 0 0",
|
||||
"v 3 0 0",
|
||||
"v 3 3 0",
|
||||
"v 2 3 0",
|
||||
"v 2 1 0",
|
||||
"v 1 1 0",
|
||||
"v 1 3 0",
|
||||
"v 0 3 0",
|
||||
"f 1 2 3 4 5 6 7 8",
|
||||
].join("\n"));
|
||||
|
||||
const positions = shape.importedMesh?.positions ?? [];
|
||||
let triangleArea = 0;
|
||||
for (let index = 0; index < positions.length; index += 9) {
|
||||
const ax = positions[index];
|
||||
const ay = positions[index + 1];
|
||||
const bx = positions[index + 3];
|
||||
const by = positions[index + 4];
|
||||
const cx = positions[index + 6];
|
||||
const cy = positions[index + 7];
|
||||
triangleArea += Math.abs((bx - ax) * (cy - ay) - (by - ay) * (cx - ax)) / 2;
|
||||
}
|
||||
|
||||
expect(shape.importedMesh?.triangleCount).toBe(6);
|
||||
expect(triangleArea).toBeCloseTo(7, 6);
|
||||
});
|
||||
|
||||
it("re-imports SketchForge Z-up OBJ exports into the editor's Y-up coordinates", () => {
|
||||
const shape = importedShapeFromObj("roundtrip.obj", [
|
||||
"# SketchForge OBJ export",
|
||||
"# Z-up triangle soup, matching SketchForge STL export",
|
||||
"v 0 0 0",
|
||||
"v 2 0 0",
|
||||
"v 0 0 3",
|
||||
"vn 0 1 0",
|
||||
"f 1//1 2//1 3//1",
|
||||
].join("\n"));
|
||||
|
||||
expect(shape.width).toBe(2);
|
||||
expect(shape.height).toBe(3);
|
||||
expect(shape.depth).toBe(1);
|
||||
expect(shape.importedMesh?.positions).toEqual([
|
||||
-1, 0, 0,
|
||||
-1, 3, 0,
|
||||
1, 0, 0,
|
||||
]);
|
||||
});
|
||||
it("uses OBJ normals to correct reversed triangle winding", () => {
|
||||
const shape = importedShapeFromObj("reversed.obj", [
|
||||
"v 0 0 0",
|
||||
"v 2 0 0",
|
||||
"v 0 2 0",
|
||||
"vt 0 0",
|
||||
"vt 1 0",
|
||||
"vt 0 1",
|
||||
"vn 0 0 -1",
|
||||
"f 1/1/1 2/2/1 3/3/1",
|
||||
].join("\n"));
|
||||
|
||||
const positions = shape.importedMesh?.positions ?? [];
|
||||
const normals = shape.importedMesh?.normals ?? [];
|
||||
const ab = [
|
||||
positions[3] - positions[0],
|
||||
positions[4] - positions[1],
|
||||
positions[5] - positions[2],
|
||||
];
|
||||
const ac = [
|
||||
positions[6] - positions[0],
|
||||
positions[7] - positions[1],
|
||||
positions[8] - positions[2],
|
||||
];
|
||||
const geometricNormal = [
|
||||
ab[1] * ac[2] - ab[2] * ac[1],
|
||||
ab[2] * ac[0] - ab[0] * ac[2],
|
||||
ab[0] * ac[1] - ab[1] * ac[0],
|
||||
];
|
||||
const dot = geometricNormal[0] * normals[0] + geometricNormal[1] * normals[1] + geometricNormal[2] * normals[2];
|
||||
|
||||
expect(dot).toBeGreaterThan(0);
|
||||
expect(shape.importedMesh?.triangleCount).toBe(1);
|
||||
});
|
||||
it("rejects OBJ files without mesh faces", () => {
|
||||
expect(() => importedShapeFromObj("points.obj", "v 0 0 0\nv 1 1 1")).toThrow("OBJ has no readable mesh geometry");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
import { promises as fs } from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { DELETE, GET } from "@/app/api/shared-projects/route";
|
||||
|
||||
const SHARED_PROJECTS_ENV = "SKETCHFORGE_SHARED_PROJECTS_DIR";
|
||||
|
||||
let sharedProjectsRoot = "";
|
||||
let previousSharedProjectsRoot: string | undefined;
|
||||
|
||||
async function createSharedProject(fileName: string, content = "shared project") {
|
||||
await fs.writeFile(path.join(sharedProjectsRoot, fileName), content);
|
||||
const response = await GET(new Request("http://localhost/api/shared-projects"));
|
||||
const payload = await response.json() as { projects: Array<{ fileName: string; revision: string }> };
|
||||
const project = payload.projects.find((candidate) => candidate.fileName === fileName);
|
||||
if (!project) throw new Error(`Could not find ${fileName} in shared project listing`);
|
||||
return project;
|
||||
}
|
||||
|
||||
function deleteRequest(fileName: string, revision?: string, origin = "http://localhost") {
|
||||
const headers = new Headers({ Origin: origin });
|
||||
if (revision) headers.set("If-Match", `"${revision}"`);
|
||||
return new Request(`http://localhost/api/shared-projects?fileName=${encodeURIComponent(fileName)}`, {
|
||||
method: "DELETE",
|
||||
headers,
|
||||
});
|
||||
}
|
||||
|
||||
describe("shared project deletion", () => {
|
||||
beforeEach(async () => {
|
||||
previousSharedProjectsRoot = process.env[SHARED_PROJECTS_ENV];
|
||||
sharedProjectsRoot = await fs.mkdtemp(path.join(os.tmpdir(), "sketchforge-shared-delete-"));
|
||||
process.env[SHARED_PROJECTS_ENV] = sharedProjectsRoot;
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
if (previousSharedProjectsRoot === undefined) delete process.env[SHARED_PROJECTS_ENV];
|
||||
else process.env[SHARED_PROJECTS_ENV] = previousSharedProjectsRoot;
|
||||
await fs.rm(sharedProjectsRoot, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it("deletes a shared project when the listed revision still matches", async () => {
|
||||
const project = await createSharedProject("Delete me.skf");
|
||||
|
||||
const response = await DELETE(deleteRequest(project.fileName, project.revision));
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
await expect(fs.access(path.join(sharedProjectsRoot, project.fileName))).rejects.toThrow();
|
||||
expect(await response.json()).toEqual({ deleted: true, fileName: project.fileName });
|
||||
});
|
||||
|
||||
it("refuses to delete from a stale dashboard revision", async () => {
|
||||
const project = await createSharedProject("Changed model.skf");
|
||||
|
||||
const response = await DELETE(deleteRequest(project.fileName, "stale-revision"));
|
||||
|
||||
expect(response.status).toBe(409);
|
||||
await expect(fs.access(path.join(sharedProjectsRoot, project.fileName))).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it("requires a revision precondition before deleting", async () => {
|
||||
const project = await createSharedProject("Needs revision.skf");
|
||||
|
||||
const response = await DELETE(deleteRequest(project.fileName));
|
||||
|
||||
expect(response.status).toBe(428);
|
||||
await expect(fs.access(path.join(sharedProjectsRoot, project.fileName))).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it("rejects cross-origin delete requests", async () => {
|
||||
const project = await createSharedProject("Protected model.skf");
|
||||
|
||||
const response = await DELETE(deleteRequest(project.fileName, project.revision, "https://example.invalid"));
|
||||
|
||||
expect(response.status).toBe(403);
|
||||
await expect(fs.access(path.join(sharedProjectsRoot, project.fileName))).resolves.toBeUndefined();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user