Extend the existing NewSpaceDialog project flow so an optional host folder becomes the space workspace root. When .git metadata is present, remote URL, default branch, and head commit are stored on the space. Team Computer file APIs expose the linked folder under project/ without a second VCS stack. Desktop adds a native folder picker; web falls back to an absolute path field. Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { mkdtempSync, rmSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
import {
|
|
isProjectWorkspacePath,
|
|
projectWorkspaceRelativePath,
|
|
resolveProjectHostPath,
|
|
} from "./project-workspace-path.js";
|
|
|
|
describe("project workspace paths", () => {
|
|
const roots: string[] = [];
|
|
|
|
afterEach(() => {
|
|
for (const root of roots.splice(0)) {
|
|
rmSync(root, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
it("detects project-root paths", () => {
|
|
expect(isProjectWorkspacePath("project")).toBe(true);
|
|
expect(isProjectWorkspacePath("project/src/main.ts")).toBe(true);
|
|
expect(isProjectWorkspacePath("shared/notes.txt")).toBe(false);
|
|
});
|
|
|
|
it("resolves host paths under the linked project folder", () => {
|
|
const root = mkdtempSync(path.join(tmpdir(), "project-workspace-path-"));
|
|
roots.push(root);
|
|
expect(resolveProjectHostPath(root, "project")).toBe(path.resolve(root));
|
|
expect(resolveProjectHostPath(root, "project/src/app.ts")).toBe(
|
|
path.resolve(root, "src/app.ts"),
|
|
);
|
|
expect(() => resolveProjectHostPath(root, "project/../outside")).toThrow(/escapes/i);
|
|
});
|
|
|
|
it("extracts relative segments from stored paths", () => {
|
|
expect(projectWorkspaceRelativePath("project")).toBe("");
|
|
expect(projectWorkspaceRelativePath("project/docs/readme.md")).toBe("docs/readme.md");
|
|
});
|
|
});
|