mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
* feat(cli): share rendered videos through unified reviews (#7135) * feat(share): attach editable project sources to reviews (#7137) * feat(share): measure local sharing outcomes (#7138) * feat(cli): stage the sixty-day publish transition (#7136) * feat(studio): share review pages from local preview (#7140) Advertise the CLI sharing bridge before bootstrapping it so standalone Studio does not request unsupported routes. Preserve origin and session checks. Budget the intended sharing artifact: clean main packs at 8,060,519 bytes versus 8,162,979 with sharing (8,169,168 in CI). Required policy and Unicode tables, bundled sharing code, and Studio controls account for the growth. Set the packed-only budget to 8,577,627, following the 5% headroom convention; retain the unpacked cap and all package checks. * fix(share): persist refusals and improve CLI retry feedback * fix(ci): restore render diagnostics and include sharing workspace * fix(cli): keep sharing owner error codes stable * fix(share): clarify update feedback and align audience changes * fix(share): clarify updates and avoid scratch-file rerenders * fix(cli): report active shares and preserve update channels * fix(cli): resolve update channel when checking registry * fix(ci): refresh sharing package budgets after rebase * fix(share): require consent before uploading project files
138 lines
4.9 KiB
TypeScript
138 lines
4.9 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join, basename } from "node:path";
|
|
import { InvalidProjectError, resolveLintTarget, resolveProjectOrThrow } from "./project.js";
|
|
|
|
describe("resolveProjectOrThrow", () => {
|
|
it("rejects # as a project directory with a helpful message", () => {
|
|
try {
|
|
resolveProjectOrThrow("#");
|
|
expect.unreachable("expected InvalidProjectError");
|
|
} catch (err) {
|
|
expect(err).toBeInstanceOf(InvalidProjectError);
|
|
const error = err as InvalidProjectError;
|
|
expect(error.title).toBe("Invalid project directory: #");
|
|
expect(error.hint).toContain("URL fragment");
|
|
expect(error.suggestion).toContain("hyperframes preview .");
|
|
}
|
|
});
|
|
|
|
it("rejects a missing directory", () => {
|
|
const missing = join(tmpdir(), `hf-missing-${Date.now()}`);
|
|
expect(() => resolveProjectOrThrow(missing)).toThrowError(/Not a directory/);
|
|
});
|
|
|
|
it("names the project folder when given a file inside it", () => {
|
|
const dir = mkdtempSync(join(tmpdir(), "hf-file-arg-project-"));
|
|
try {
|
|
mkdirSync(join(dir, "assets"));
|
|
writeFileSync(join(dir, "index.html"), "<html></html>");
|
|
writeFileSync(join(dir, "assets", "music.mp3"), "x");
|
|
const file = join(dir, "assets", "music.mp3");
|
|
expect(() => resolveProjectOrThrow(file)).toThrowError(
|
|
expect.objectContaining({
|
|
title: "Not a directory: " + file,
|
|
hint: "music.mp3 is a file; this command takes the project folder.",
|
|
suggestion: "Pass the folder that holds index.html: " + dir,
|
|
}),
|
|
);
|
|
} finally {
|
|
rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
it("rejects a directory without index.html", () => {
|
|
const dir = mkdtempSync(join(tmpdir(), "hf-empty-project-"));
|
|
try {
|
|
expect(() => resolveProjectOrThrow(dir)).toThrowError(/No composition found/);
|
|
} finally {
|
|
rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
it("accepts a directory without index.html when an explicit entry will be resolved", () => {
|
|
const dir = mkdtempSync(join(tmpdir(), "hf-explicit-entry-project-"));
|
|
try {
|
|
const project = resolveProjectOrThrow(dir, { requireIndex: false });
|
|
expect(project.dir).toBe(dir);
|
|
expect(project.indexPath).toBe(join(dir, "index.html"));
|
|
expect(project.name).toBe(basename(dir));
|
|
} finally {
|
|
rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
it("accepts a directory with index.html", () => {
|
|
const dir = mkdtempSync(join(tmpdir(), "hf-valid-project-"));
|
|
try {
|
|
writeFileSync(join(dir, "index.html"), '<html data-composition-id="test"></html>');
|
|
const project = resolveProjectOrThrow(dir);
|
|
expect(project.dir).toBe(dir);
|
|
expect(project.indexPath).toBe(join(dir, "index.html"));
|
|
expect(project.name).toBe(basename(dir));
|
|
} finally {
|
|
rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|
|
|
|
describe("resolveLintTarget", () => {
|
|
const project = () => {
|
|
const dir = mkdtempSync(join(tmpdir(), "hf-lint-target-"));
|
|
mkdirSync(join(dir, "compositions"));
|
|
writeFileSync(join(dir, "index.html"), "<html></html>");
|
|
writeFileSync(join(dir, "compositions", "intro.html"), "<template></template>");
|
|
return dir;
|
|
};
|
|
|
|
it("takes a composition file as the entry of the project that holds it", () => {
|
|
const dir = project();
|
|
try {
|
|
const file = join(dir, "compositions", "intro.html");
|
|
const target = resolveLintTarget(file);
|
|
expect(target.entryFile).toBe(file);
|
|
expect(target.project.dir).toBe(dir);
|
|
} finally {
|
|
rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
it("lints a project's own index.html as the whole project", () => {
|
|
const dir = project();
|
|
try {
|
|
const target = resolveLintTarget(join(dir, "index.html"));
|
|
expect(target.entryFile).toBeUndefined();
|
|
expect(target.project.dir).toBe(dir);
|
|
} finally {
|
|
rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
it("still takes a directory", () => {
|
|
const dir = project();
|
|
try {
|
|
expect(resolveLintTarget(dir)).toEqual({ project: resolveProjectOrThrow(dir) });
|
|
} finally {
|
|
rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
});
|
|
|
|
it("finds a parent project only when no directory was explicitly supplied", () => {
|
|
const dir = mkdtempSync(join(tmpdir(), "hf-parent-project-"));
|
|
const child = join(dir, "compositions");
|
|
mkdirSync(child);
|
|
writeFileSync(join(dir, "index.html"), "<html></html>");
|
|
const cwd = vi.spyOn(process, "cwd").mockReturnValue(child);
|
|
try {
|
|
expect(resolveProjectOrThrow(undefined, { searchParents: true }).dir).toBe(dir);
|
|
expect(() => resolveProjectOrThrow(child, { searchParents: true })).toThrow(
|
|
"No composition found",
|
|
);
|
|
} finally {
|
|
cwd.mockRestore();
|
|
rmSync(dir, { recursive: true, force: true });
|
|
}
|
|
});
|