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
release: publish v1.0.0
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { appUpdateIsAvailable, compareAppVersions } from "@/lib/appUpdates";
|
||||
|
||||
describe("application update versions", () => {
|
||||
it("orders semantic releases numerically", () => {
|
||||
expect(compareAppVersions("0.10.0", "0.9.9")).toBeGreaterThan(0);
|
||||
expect(compareAppVersions("1.0.0", "0.99.99")).toBeGreaterThan(0);
|
||||
expect(compareAppVersions("v1.0.0", "1.0.0")).toBe(0);
|
||||
});
|
||||
|
||||
it("keeps prereleases below their stable release", () => {
|
||||
expect(compareAppVersions("1.0.0-beta.2", "1.0.0-beta.1")).toBeGreaterThan(0);
|
||||
expect(compareAppVersions("1.0.0", "1.0.0-rc.1")).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("only offers a strictly newer version", () => {
|
||||
expect(appUpdateIsAvailable("1.0.0", "1.0.1")).toBe(true);
|
||||
expect(appUpdateIsAvailable("1.0.0", "1.0.0")).toBe(false);
|
||||
expect(appUpdateIsAvailable("1.0.0", "0.9.9")).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { CHALLENGE_TUTORIAL_IDS, isChallengeTutorialId } from "@/lib/challenges";
|
||||
|
||||
describe("challenge tutorial ids", () => {
|
||||
it("recognizes every supported challenge", () => {
|
||||
expect(CHALLENGE_TUTORIAL_IDS).toEqual(["key-tag", "nameplate"]);
|
||||
expect(CHALLENGE_TUTORIAL_IDS.every(isChallengeTutorialId)).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects stale or malformed stored values", () => {
|
||||
expect(isChallengeTutorialId("phone-stand")).toBe(false);
|
||||
expect(isChallengeTutorialId(null)).toBe(false);
|
||||
expect(isChallengeTutorialId({ tutorial: "nameplate" })).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { sketchForgeToZUp, zUpToSketchForge } from "@/lib/meshCoordinates";
|
||||
|
||||
describe("mesh coordinate conventions", () => {
|
||||
it("maps slicer Z-up coordinates to SketchForge Y-up and back", () => {
|
||||
const slicerPoint: [number, number, number] = [12, 34, 56];
|
||||
const sketchForgePoint = zUpToSketchForge(slicerPoint);
|
||||
|
||||
expect(sketchForgePoint).toEqual([12, 56, -34]);
|
||||
expect(sketchForgeToZUp(sketchForgePoint)).toEqual(slicerPoint);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { exportMeshesToObj, type ObjExportMesh } from "@/lib/objExport";
|
||||
|
||||
function duplicatedTetrahedron(): ObjExportMesh {
|
||||
const a: [number, number, number] = [0, 0, 0];
|
||||
const b: [number, number, number] = [10, 0, 0];
|
||||
const c: [number, number, number] = [0, 10, 0];
|
||||
const d: [number, number, number] = [0, 0, 10];
|
||||
return {
|
||||
name: "closed_tetrahedron",
|
||||
vertices: [a, c, b, a, b, d, b, c, d, c, a, d],
|
||||
faces: [[0, 1, 2], [3, 4, 5], [6, 7, 8], [9, 10, 11]],
|
||||
};
|
||||
}
|
||||
|
||||
describe("OBJ export", () => {
|
||||
it("preserves OBJ's conventional Y-up coordinates", () => {
|
||||
const obj = exportMeshesToObj([duplicatedTetrahedron()]);
|
||||
const vertices = obj.split("\n").filter((line) => line.startsWith("v "));
|
||||
|
||||
expect(vertices).toContain("v 0 0 10");
|
||||
expect(vertices).toContain("v 0 10 0");
|
||||
});
|
||||
|
||||
it("welds coincident triangle vertices so a closed mesh has no boundary edges", () => {
|
||||
const obj = exportMeshesToObj([duplicatedTetrahedron()]);
|
||||
const vertices = obj.split("\n").filter((line) => line.startsWith("v "));
|
||||
const faces = obj.split("\n").filter((line) => line.startsWith("f "));
|
||||
const edgeUse = new Map<string, number>();
|
||||
|
||||
faces.forEach((line) => {
|
||||
const [a, b, c] = line.slice(2).trim().split(/\s+/).map(Number);
|
||||
[[a, b], [b, c], [c, a]].forEach(([start, end]) => {
|
||||
const key = start < end ? `${start}:${end}` : `${end}:${start}`;
|
||||
edgeUse.set(key, (edgeUse.get(key) ?? 0) + 1);
|
||||
});
|
||||
});
|
||||
|
||||
expect(vertices).toHaveLength(4);
|
||||
expect(faces).toHaveLength(4);
|
||||
expect([...edgeUse.values()].every((count) => count === 2)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,118 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { cadSketchRegions, orderedCadSketchPaths } from "@/lib/sketchCadProfile";
|
||||
import type { SketchPoint, SketchProfile, SketchSegment } from "@/types/sketchforge";
|
||||
|
||||
function rectangle(id: string, x: number, z: number, width: number, depth: number) {
|
||||
const points: SketchPoint[] = [
|
||||
{ id: `${id}-0`, x, z },
|
||||
{ id: `${id}-1`, x: x + width, z },
|
||||
{ id: `${id}-2`, x: x + width, z: z + depth },
|
||||
{ id: `${id}-3`, x, z: z + depth },
|
||||
];
|
||||
const segments: SketchSegment[] = points.map((point, index) => ({
|
||||
id: `${id}-s${index}`,
|
||||
kind: "line",
|
||||
startId: point.id,
|
||||
endId: points[(index + 1) % points.length].id,
|
||||
}));
|
||||
return { points, segments };
|
||||
}
|
||||
|
||||
function profile(...rectangles: ReturnType<typeof rectangle>[]): SketchProfile {
|
||||
return {
|
||||
points: rectangles.flatMap((rectangle) => rectangle.points),
|
||||
segments: rectangles.flatMap((rectangle) => rectangle.segments),
|
||||
};
|
||||
}
|
||||
|
||||
describe("OCCT sketch profile preparation", () => {
|
||||
it("orders a closed loop even when its segments arrive out of order", () => {
|
||||
const square = rectangle("outer", 0, 0, 20, 10);
|
||||
const paths = orderedCadSketchPaths({ ...profile(square), segments: [...square.segments].reverse() });
|
||||
expect(paths).toHaveLength(1);
|
||||
expect(paths[0].closed).toBe(true);
|
||||
expect(paths[0].steps).toHaveLength(4);
|
||||
});
|
||||
|
||||
it("assigns an enclosed loop as a hole", () => {
|
||||
const regions = cadSketchRegions(profile(
|
||||
rectangle("outer", 0, 0, 20, 20),
|
||||
rectangle("hole", 5, 5, 4, 4),
|
||||
));
|
||||
expect(regions).toHaveLength(1);
|
||||
expect(regions[0].outer.id).toContain("outer");
|
||||
expect(regions[0].holes).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("keeps disjoint loops as separate solids", () => {
|
||||
const regions = cadSketchRegions(profile(
|
||||
rectangle("left", 0, 0, 4, 4),
|
||||
rectangle("right", 10, 0, 4, 4),
|
||||
));
|
||||
expect(regions).toHaveLength(2);
|
||||
expect(regions.every((region) => region.holes.length === 0)).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects open paths with a clear error", () => {
|
||||
const square = rectangle("open", 0, 0, 10, 10);
|
||||
square.segments.pop();
|
||||
expect(() => cadSketchRegions(profile(square))).toThrow(/open/i);
|
||||
});
|
||||
|
||||
it("creates a solid island inside a hole (3-level nesting)", () => {
|
||||
const regions = cadSketchRegions(profile(
|
||||
rectangle("outer", 0, 0, 40, 40),
|
||||
rectangle("hole", 5, 5, 30, 30),
|
||||
rectangle("island", 12, 12, 16, 16),
|
||||
));
|
||||
expect(regions).toHaveLength(2);
|
||||
const outerRegion = regions.find((r) => r.outer.id.includes("outer"));
|
||||
const islandRegion = regions.find((r) => r.outer.id.includes("island"));
|
||||
expect(outerRegion).toBeDefined();
|
||||
expect(outerRegion!.holes).toHaveLength(1);
|
||||
expect(outerRegion!.holes[0].id).toContain("hole");
|
||||
expect(islandRegion).toBeDefined();
|
||||
expect(islandRegion!.holes).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("handles 4-level nesting (outer > hole > island > island-hole)", () => {
|
||||
const regions = cadSketchRegions(profile(
|
||||
rectangle("outer", 0, 0, 60, 60),
|
||||
rectangle("hole", 5, 5, 50, 50),
|
||||
rectangle("island", 15, 15, 30, 30),
|
||||
rectangle("ihole", 20, 20, 20, 20),
|
||||
));
|
||||
const outerRegion = regions.find((r) => r.outer.id.includes("outer"));
|
||||
const islandRegion = regions.find((r) => r.outer.id.includes("island"));
|
||||
expect(outerRegion).toBeDefined();
|
||||
expect(outerRegion!.holes).toHaveLength(1);
|
||||
expect(outerRegion!.holes[0].id).toContain("hole");
|
||||
expect(islandRegion).toBeDefined();
|
||||
expect(islandRegion!.holes).toHaveLength(1);
|
||||
expect(islandRegion!.holes[0].id).toContain("ihole");
|
||||
});
|
||||
|
||||
it("throws when all paths are open", () => {
|
||||
const open1 = rectangle("a", 0, 0, 10, 10);
|
||||
open1.segments.pop();
|
||||
const open2 = rectangle("b", 20, 0, 10, 10);
|
||||
open2.segments.pop();
|
||||
expect(() => cadSketchRegions(profile(open1, open2))).toThrow(/open/i);
|
||||
});
|
||||
|
||||
it("returns empty for a single degenerate zero-area path", () => {
|
||||
const degenerate: SketchProfile = {
|
||||
points: [
|
||||
{ id: "d-0", x: 0, z: 0 },
|
||||
{ id: "d-1", x: 1, z: 0 },
|
||||
{ id: "d-2", x: 0, z: 0 },
|
||||
],
|
||||
segments: [
|
||||
{ id: "d-s0", kind: "line", startId: "d-0", endId: "d-1" },
|
||||
{ id: "d-s1", kind: "line", startId: "d-1", endId: "d-2" },
|
||||
{ id: "d-s2", kind: "line", startId: "d-2", endId: "d-0" },
|
||||
],
|
||||
};
|
||||
expect(cadSketchRegions(degenerate)).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { exportMeshesToStl } from "@/lib/stlExport";
|
||||
|
||||
describe("STL export orientation", () => {
|
||||
it("writes editor Y-up coordinates as slicer Z-up coordinates", () => {
|
||||
const stl = exportMeshesToStl([{
|
||||
vertices: [[0, 0, 0], [10, 0, 0], [0, 20, 5]],
|
||||
faces: [[0, 1, 2]],
|
||||
}]);
|
||||
|
||||
expect(stl).toContain("vertex 0 -5 20");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,48 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { importedShapeFromStl } from "@/lib/stlImport";
|
||||
|
||||
function boxStl(width: number, ySize: number, zSize: number, name = "box") {
|
||||
const vertices = [
|
||||
[0, 0, 0], [width, 0, 0], [width, ySize, 0], [0, ySize, 0],
|
||||
[0, 0, zSize], [width, 0, zSize], [width, ySize, zSize], [0, ySize, zSize],
|
||||
];
|
||||
const faces = [
|
||||
[0, 2, 1], [0, 3, 2], [4, 5, 6], [4, 6, 7],
|
||||
[0, 1, 5], [0, 5, 4], [1, 2, 6], [1, 6, 5],
|
||||
[2, 3, 7], [2, 7, 6], [3, 0, 4], [3, 4, 7],
|
||||
];
|
||||
const facets = faces.map(([a, b, c]) => `facet normal 0 0 0
|
||||
outer loop
|
||||
vertex ${vertices[a].join(" ")}
|
||||
vertex ${vertices[b].join(" ")}
|
||||
vertex ${vertices[c].join(" ")}
|
||||
endloop
|
||||
endfacet`).join("\n");
|
||||
const source = `solid ${name}\n${facets}\nendsolid ${name}`;
|
||||
return new TextEncoder().encode(source).buffer;
|
||||
}
|
||||
|
||||
describe("STL import orientation", () => {
|
||||
it("maps a clearly Z-up slicer model to SketchForge Y-up", () => {
|
||||
const shape = importedShapeFromStl("z-up-box.stl", boxStl(80, 60, 20));
|
||||
|
||||
expect(shape.importedMesh?.baseWidth).toBeCloseTo(80);
|
||||
expect(shape.importedMesh?.baseHeight).toBeCloseTo(20);
|
||||
expect(shape.importedMesh?.baseDepth).toBeCloseTo(60);
|
||||
});
|
||||
|
||||
it("preserves an unmistakably flat Y-up legacy model", () => {
|
||||
const shape = importedShapeFromStl("raspberry-pi-like.stl", boxStl(89, 20, 58));
|
||||
|
||||
expect(shape.importedMesh?.baseWidth).toBeCloseTo(89);
|
||||
expect(shape.importedMesh?.baseHeight).toBeCloseTo(20);
|
||||
expect(shape.importedMesh?.baseDepth).toBeCloseTo(58);
|
||||
});
|
||||
|
||||
it("preserves previous SketchForge STL exports regardless of proportions", () => {
|
||||
const shape = importedShapeFromStl("legacy-sketchforge.stl", boxStl(20, 80, 10, "sketchforge_design"));
|
||||
|
||||
expect(shape.importedMesh?.baseHeight).toBeCloseTo(80);
|
||||
expect(shape.importedMesh?.baseDepth).toBeCloseTo(10);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user