Files
frames/packages/studio/vite.producer.test.ts
zooqueen 75094e0d60 frames: publish the toolchain as @hanzo/frames
@hanzo/frame is taken by the hero video primitive — one full-bleed video
element — which has held that name on npm since it shipped. This repo is the
video toolchain: a CLI, a renderer, a studio, a player. Plural is what it is,
so the CLI publishes as @hanzo/frames and the workspace packages follow it
(@hanzo/frames-core, @hanzo/frames-engine, and the rest).

The binary stays `frames`, and now actually ships. The manifest mapped it to
bin/frames.mjs while the file on disk was bin/hyperframes.mjs, so a global
install produced no working command.

The paths that name a package to fetch were pointing elsewhere. The update
check read registry.npmjs.org/frames, a different author's package, and the
npm, bun and pnpm installers would have pulled it over the CLI; the render
image installed the upstream hyperframes; scaffolded projects and the docs
pinned the unscoped name. All of them now name @hanzo/frames.
2026-08-13 18:10:14 -07:00

87 lines
2.6 KiB
TypeScript

import { resolve } from "node:path";
import { describe, expect, it, vi } from "vitest";
import {
createRetryingModuleLoader,
ensureProducerDist,
resolveProducerDistEntry,
resolveWorkspaceRoot,
} from "./vite.producer";
describe("ensureProducerDist", () => {
it("does nothing when the producer dist entry already exists", () => {
const exec = vi.fn();
const result = ensureProducerDist({
studioDir: "/repo/packages/studio",
existsSyncImpl: () => true,
execFileSyncImpl: exec as never,
});
expect(result).toEqual({
built: false,
producerDistEntry: resolve("/repo/packages/producer/dist/index.js"),
});
expect(exec).not.toHaveBeenCalled();
});
it("builds producer when the dist entry is missing", () => {
const exec = vi.fn();
const env = { TEST: "1" } as NodeJS.ProcessEnv;
const result = ensureProducerDist({
studioDir: "/repo/packages/studio",
existsSyncImpl: () => false,
execFileSyncImpl: exec as never,
env,
});
expect(result).toEqual({
built: true,
producerDistEntry: resolve("/repo/packages/producer/dist/index.js"),
});
expect(exec).toHaveBeenCalledWith(
"bun",
["run", "--filter", "@hanzo/frames-producer", "build"],
{
cwd: resolve("/repo"),
stdio: "pipe",
env,
},
);
});
});
describe("producer path helpers", () => {
it("resolves the producer dist entry relative to studio", () => {
expect(resolveProducerDistEntry("/repo/packages/studio")).toBe(
resolve("/repo/packages/producer/dist/index.js"),
);
});
it("resolves the workspace root relative to studio", () => {
expect(resolveWorkspaceRoot("/repo/packages/studio")).toBe(resolve("/repo"));
});
});
describe("createRetryingModuleLoader", () => {
it("retries after an initial load failure instead of caching the rejection", async () => {
const load = vi
.fn<() => Promise<string>>()
.mockRejectedValueOnce(new Error("boom"))
.mockResolvedValueOnce("ok");
const getModule = createRetryingModuleLoader(load);
await expect(getModule()).rejects.toThrow("boom");
await expect(getModule()).resolves.toBe("ok");
expect(load).toHaveBeenCalledTimes(2);
});
it("reuses the same promise after a successful load", async () => {
const load = vi.fn<() => Promise<string>>().mockResolvedValue("ok");
const getModule = createRetryingModuleLoader(load);
await expect(getModule()).resolves.toBe("ok");
await expect(getModule()).resolves.toBe("ok");
expect(load).toHaveBeenCalledTimes(1);
});
});