mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-03 23:03:09 +00:00
style: apply oxfmt baseline formatting across all source files (#25)
## Summary - Run `oxfmt .` across the entire codebase to establish formatted baseline - 299 files changed — mechanical formatting only, no logic changes - Double quotes, semicolons, 2-space indent, trailing commas, 100 print width Part 3/4 of [VA-851](https://linear.app/heygen/issue/VA-851/pre-migration-configure-eslint-prettier-and-conventional-commits) ## Test plan - [x] `pnpm format:check` — all 426 files pass - [x] `pnpm -r typecheck` — all packages pass - [x] `pnpm build` — all packages build - [x] All 348 tests pass
This commit is contained in:
@@ -36,7 +36,10 @@ const DEFAULT_CONFIGS: BenchmarkConfig[] = [
|
||||
];
|
||||
|
||||
export default defineCommand({
|
||||
meta: { name: "benchmark", description: "Run multiple render configurations and compare results" },
|
||||
meta: {
|
||||
name: "benchmark",
|
||||
description: "Run multiple render configurations and compare results",
|
||||
},
|
||||
args: {
|
||||
dir: { type: "positional", description: "Project directory", required: false },
|
||||
runs: { type: "string", description: "Number of runs per config", default: "3" },
|
||||
@@ -64,7 +67,9 @@ export default defineCommand({
|
||||
producer = await loadProducer();
|
||||
} catch {
|
||||
if (jsonOutput) {
|
||||
console.log(JSON.stringify({ error: "Producer module not available. Is the project built?" }));
|
||||
console.log(
|
||||
JSON.stringify({ error: "Producer module not available. Is the project built?" }),
|
||||
);
|
||||
} else {
|
||||
errorBox(
|
||||
"Producer module not available",
|
||||
@@ -99,7 +104,10 @@ export default defineCommand({
|
||||
|
||||
for (let i = 0; i < runsPerConfig; i++) {
|
||||
s?.message(`${config.label} — run ${i + 1}/${runsPerConfig}`);
|
||||
const outputPath = join(benchDir, `${config.label.replace(/[^a-zA-Z0-9]/g, "_")}_run${i}.mp4`);
|
||||
const outputPath = join(
|
||||
benchDir,
|
||||
`${config.label.replace(/[^a-zA-Z0-9]/g, "_")}_run${i}.mp4`,
|
||||
);
|
||||
|
||||
try {
|
||||
const startTime = Date.now();
|
||||
@@ -176,12 +184,9 @@ export default defineCommand({
|
||||
console.log(separator);
|
||||
|
||||
for (const result of results) {
|
||||
const timeStr =
|
||||
result.avgTime != null ? formatDuration(result.avgTime) : c.dim("failed");
|
||||
const sizeStr =
|
||||
result.avgSize != null ? formatBytes(result.avgSize) : c.dim("n/a");
|
||||
const failStr =
|
||||
result.failures > 0 ? c.warn(` (${result.failures} failed)`) : "";
|
||||
const timeStr = result.avgTime != null ? formatDuration(result.avgTime) : c.dim("failed");
|
||||
const sizeStr = result.avgSize != null ? formatBytes(result.avgSize) : c.dim("n/a");
|
||||
const failStr = result.failures > 0 ? c.warn(` (${result.failures} failed)`) : "";
|
||||
|
||||
console.log(
|
||||
" " +
|
||||
@@ -215,8 +220,7 @@ export default defineCommand({
|
||||
} else {
|
||||
console.log("");
|
||||
console.log(
|
||||
c.error("\u2717") +
|
||||
" All configurations failed. Ensure the rendering pipeline is set up.",
|
||||
c.error("\u2717") + " All configurations failed. Ensure the rendering pipeline is set up.",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,9 +30,7 @@ async function runEnsure(): Promise<void> {
|
||||
s.stop("No browser found — downloading");
|
||||
|
||||
const downloadSpinner = clack.spinner();
|
||||
downloadSpinner.start(
|
||||
`Downloading Chrome Headless Shell ${c.dim("v" + CHROME_VERSION)}...`,
|
||||
);
|
||||
downloadSpinner.start(`Downloading Chrome Headless Shell ${c.dim("v" + CHROME_VERSION)}...`);
|
||||
|
||||
let lastPct = -1;
|
||||
const result = await ensureBrowser({
|
||||
@@ -66,9 +64,7 @@ async function runPath(): Promise<void> {
|
||||
const ensured = await ensureBrowser();
|
||||
process.stdout.write(ensured.executablePath + "\n");
|
||||
} catch (err: unknown) {
|
||||
console.error(
|
||||
err instanceof Error ? err.message : "Failed to find browser",
|
||||
);
|
||||
console.error(err instanceof Error ? err.message : "Failed to find browser");
|
||||
process.exit(1);
|
||||
}
|
||||
return;
|
||||
@@ -81,9 +77,7 @@ function runClear(): void {
|
||||
|
||||
const removed = clearBrowser();
|
||||
if (removed) {
|
||||
clack.outro(
|
||||
c.success("Removed cached browser from ") + c.dim(CACHE_DIR),
|
||||
);
|
||||
clack.outro(c.success("Removed cached browser from ") + c.dim(CACHE_DIR));
|
||||
} else {
|
||||
clack.outro(c.dim("No cached browser to remove."));
|
||||
}
|
||||
@@ -92,7 +86,11 @@ function runClear(): void {
|
||||
export default defineCommand({
|
||||
meta: { name: "browser", description: "Manage the Chrome browser used for rendering" },
|
||||
args: {
|
||||
subcommand: { type: "positional", description: "Subcommand: ensure, path, clear", required: false },
|
||||
subcommand: {
|
||||
type: "positional",
|
||||
description: "Subcommand: ensure, path, clear",
|
||||
required: false,
|
||||
},
|
||||
},
|
||||
async run({ args }) {
|
||||
const subcommand = args.subcommand;
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
import { defineCommand } from "citty";
|
||||
import { spawn } from "node:child_process";
|
||||
import {
|
||||
existsSync,
|
||||
lstatSync,
|
||||
symlinkSync,
|
||||
unlinkSync,
|
||||
readlinkSync,
|
||||
mkdirSync,
|
||||
} from "node:fs";
|
||||
import { existsSync, lstatSync, symlinkSync, unlinkSync, readlinkSync, mkdirSync } from "node:fs";
|
||||
import { resolve, dirname, basename, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import * as clack from "@clack/prompts";
|
||||
@@ -181,6 +174,10 @@ async function runDevMode(dir: string): Promise<void> {
|
||||
* TODO: Migrate to use @hyperframes/studio's built-in Vite server for published CLI.
|
||||
*/
|
||||
async function runEmbeddedMode(_dir: string, _port: number): Promise<void> {
|
||||
console.error(c.error("Embedded mode not yet available. Run from the monorepo root with: hyperframes dev <dir>"));
|
||||
console.error(
|
||||
c.error(
|
||||
"Embedded mode not yet available. Run from the monorepo root with: hyperframes dev <dir>",
|
||||
),
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ function checkFFmpeg(): CheckResult {
|
||||
const path = findFFmpeg();
|
||||
if (path) {
|
||||
try {
|
||||
const version = execSync("ffmpeg -version", { encoding: "utf-8", timeout: 5000 })
|
||||
.split("\n")[0] ?? "";
|
||||
const version =
|
||||
execSync("ffmpeg -version", { encoding: "utf-8", timeout: 5000 }).split("\n")[0] ?? "";
|
||||
return { ok: true, detail: version.trim() };
|
||||
} catch {
|
||||
return { ok: true, detail: path };
|
||||
@@ -88,7 +88,6 @@ function checkNode(): CheckResult {
|
||||
return { ok: true, detail: `${process.version} (${process.platform} ${process.arch})` };
|
||||
}
|
||||
|
||||
|
||||
export default defineCommand({
|
||||
meta: { name: "doctor", description: "Check system dependencies and environment" },
|
||||
args: {},
|
||||
@@ -112,7 +111,9 @@ export default defineCommand({
|
||||
const result = await check.run();
|
||||
const icon = result.ok ? c.success("\u2713") : c.error("\u2717");
|
||||
const name = check.name.padEnd(16);
|
||||
console.log(` ${icon} ${c.bold(name)} ${result.ok ? c.dim(result.detail) : c.error(result.detail)}`);
|
||||
console.log(
|
||||
` ${icon} ${c.bold(name)} ${result.ok ? c.dim(result.detail) : c.error(result.detail)}`,
|
||||
);
|
||||
if (!result.ok && result.hint) {
|
||||
console.log(` ${" ".repeat(19)}${c.accent(result.hint)}`);
|
||||
}
|
||||
|
||||
@@ -38,8 +38,7 @@ export default defineCommand({
|
||||
(max, el) => Math.max(max, el.startTime + el.duration),
|
||||
0,
|
||||
);
|
||||
const resolution =
|
||||
parsed.resolution === "portrait" ? "1080x1920" : "1920x1080";
|
||||
const resolution = parsed.resolution === "portrait" ? "1080x1920" : "1920x1080";
|
||||
const size = totalSize(project.dir);
|
||||
|
||||
const typeCounts: Record<string, number> = {};
|
||||
@@ -51,17 +50,23 @@ export default defineCommand({
|
||||
.join(", ");
|
||||
|
||||
if (args.json) {
|
||||
console.log(JSON.stringify({
|
||||
name: project.name,
|
||||
resolution: parsed.resolution,
|
||||
width: parsed.resolution === "portrait" ? 1080 : 1920,
|
||||
height: parsed.resolution === "portrait" ? 1920 : 1080,
|
||||
duration: maxEnd,
|
||||
elements: parsed.elements.length,
|
||||
tracks: tracks.size,
|
||||
types: typeCounts,
|
||||
size,
|
||||
}, null, 2));
|
||||
console.log(
|
||||
JSON.stringify(
|
||||
{
|
||||
name: project.name,
|
||||
resolution: parsed.resolution,
|
||||
width: parsed.resolution === "portrait" ? 1080 : 1920,
|
||||
height: parsed.resolution === "portrait" ? 1920 : 1080,
|
||||
duration: maxEnd,
|
||||
elements: parsed.elements.length,
|
||||
tracks: tracks.size,
|
||||
types: typeCounts,
|
||||
size,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,10 +13,7 @@ import { fileURLToPath } from "node:url";
|
||||
import { execSync, execFileSync, spawn } from "node:child_process";
|
||||
import * as clack from "@clack/prompts";
|
||||
import { c } from "../ui/colors.js";
|
||||
import {
|
||||
TEMPLATES,
|
||||
type TemplateId,
|
||||
} from "../templates/generators.js";
|
||||
import { TEMPLATES, type TemplateId } from "../templates/generators.js";
|
||||
|
||||
const ALL_TEMPLATE_IDS = TEMPLATES.map((t) => t.id);
|
||||
|
||||
@@ -53,7 +50,14 @@ function probeVideo(filePath: string): VideoMeta | undefined {
|
||||
);
|
||||
|
||||
const parsed: {
|
||||
streams?: { codec_type?: string; codec_name?: string; width?: number; height?: number; r_frame_rate?: string; avg_frame_rate?: string }[];
|
||||
streams?: {
|
||||
codec_type?: string;
|
||||
codec_name?: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
r_frame_rate?: string;
|
||||
avg_frame_rate?: string;
|
||||
}[];
|
||||
format?: { duration?: string };
|
||||
} = JSON.parse(raw);
|
||||
|
||||
@@ -75,8 +79,7 @@ function probeVideo(filePath: string): VideoMeta | undefined {
|
||||
}
|
||||
|
||||
const durationStr = parsed.format?.duration;
|
||||
const durationSeconds =
|
||||
durationStr !== undefined ? parseFloat(durationStr) : 5;
|
||||
const durationSeconds = durationStr !== undefined ? parseFloat(durationStr) : 5;
|
||||
|
||||
return {
|
||||
durationSeconds: Number.isNaN(durationSeconds) ? 5 : durationSeconds,
|
||||
@@ -106,12 +109,26 @@ function hasFFmpeg(): boolean {
|
||||
|
||||
function transcodeToMp4(inputPath: string, outputPath: string): Promise<boolean> {
|
||||
return new Promise((resolvePromise) => {
|
||||
const child = spawn("ffmpeg", [
|
||||
"-i", inputPath,
|
||||
"-c:v", "libx264", "-preset", "fast", "-crf", "18",
|
||||
"-c:a", "aac", "-b:a", "192k",
|
||||
"-y", outputPath,
|
||||
], { stdio: "pipe" });
|
||||
const child = spawn(
|
||||
"ffmpeg",
|
||||
[
|
||||
"-i",
|
||||
inputPath,
|
||||
"-c:v",
|
||||
"libx264",
|
||||
"-preset",
|
||||
"fast",
|
||||
"-crf",
|
||||
"18",
|
||||
"-c:a",
|
||||
"aac",
|
||||
"-b:a",
|
||||
"192k",
|
||||
"-y",
|
||||
outputPath,
|
||||
],
|
||||
{ stdio: "pipe" },
|
||||
);
|
||||
|
||||
child.on("close", (code) => resolvePromise(code === 0));
|
||||
child.on("error", () => resolvePromise(false));
|
||||
@@ -133,8 +150,8 @@ function getStaticTemplateDir(templateId: string): string {
|
||||
|
||||
function patchVideoSrc(dir: string, videoFilename: string | undefined): void {
|
||||
const htmlFiles = readdirSync(dir, { withFileTypes: true, recursive: true })
|
||||
.filter(e => e.isFile() && e.name.endsWith(".html"))
|
||||
.map(e => join(e.parentPath ?? e.path, e.name));
|
||||
.filter((e) => e.isFile() && e.name.endsWith(".html"))
|
||||
.map((e) => join(e.parentPath ?? e.path, e.name));
|
||||
|
||||
for (const file of htmlFiles) {
|
||||
let content = readFileSync(file, "utf-8");
|
||||
@@ -319,7 +336,11 @@ export default defineCommand({
|
||||
meta: { name: "init", description: "Scaffold a new composition project" },
|
||||
args: {
|
||||
name: { type: "positional", description: "Project name", required: false },
|
||||
template: { type: "string", description: `Template: ${ALL_TEMPLATE_IDS.join(", ")}`, alias: "t" },
|
||||
template: {
|
||||
type: "string",
|
||||
description: `Template: ${ALL_TEMPLATE_IDS.join(", ")}`,
|
||||
alias: "t",
|
||||
},
|
||||
video: { type: "string", description: "Path to a source video file", alias: "V" },
|
||||
},
|
||||
async run({ args }) {
|
||||
@@ -340,9 +361,7 @@ export default defineCommand({
|
||||
const destDir = resolve(name);
|
||||
|
||||
if (existsSync(destDir) && readdirSync(destDir).length > 0) {
|
||||
console.error(
|
||||
c.error(`Directory already exists and is not empty: ${name}`),
|
||||
);
|
||||
console.error(c.error(`Directory already exists and is not empty: ${name}`));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -482,10 +501,7 @@ export default defineCommand({
|
||||
scaffoldProject(destDir, name, templateId, localVideoName);
|
||||
|
||||
const files = readdirSync(destDir);
|
||||
clack.note(
|
||||
files.map((f) => c.accent(f)).join("\n"),
|
||||
c.success(`Created ${name}/`),
|
||||
);
|
||||
clack.note(files.map((f) => c.accent(f)).join("\n"), c.success(`Created ${name}/`));
|
||||
|
||||
await nextStepLoop(destDir);
|
||||
},
|
||||
|
||||
@@ -38,7 +38,9 @@ export default defineCommand({
|
||||
}
|
||||
|
||||
const summaryIcon = result.errorCount > 0 ? c.error("◇") : c.success("◇");
|
||||
console.log(`\n${summaryIcon} ${result.errorCount} error(s), ${result.warningCount} warning(s)`);
|
||||
console.log(
|
||||
`\n${summaryIcon} ${result.errorCount} error(s), ${result.warningCount} warning(s)`,
|
||||
);
|
||||
process.exit(result.errorCount > 0 ? 1 : 0);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -55,9 +55,7 @@ export default defineCommand({
|
||||
|
||||
// ── Resolve output path ───────────────────────────────────────────────
|
||||
const rendersDir = resolve("renders");
|
||||
const outputPath = args.output
|
||||
? resolve(args.output)
|
||||
: join(rendersDir, `${project.name}.mp4`);
|
||||
const outputPath = args.output ? resolve(args.output) : join(rendersDir, `${project.name}.mp4`);
|
||||
|
||||
// Ensure output directory exists
|
||||
const outputDir = dirname(outputPath);
|
||||
@@ -73,8 +71,15 @@ export default defineCommand({
|
||||
const workerCount = workers ?? 4;
|
||||
if (!quiet) {
|
||||
console.log("");
|
||||
console.log(c.accent("\u25C6") + " Rendering " + c.accent(project.name) + c.dim(" \u2192 " + outputPath));
|
||||
console.log(c.dim(" " + fps + "fps \u00B7 " + quality + " \u00B7 " + workerCount + " workers"));
|
||||
console.log(
|
||||
c.accent("\u25C6") +
|
||||
" Rendering " +
|
||||
c.accent(project.name) +
|
||||
c.dim(" \u2192 " + outputPath),
|
||||
);
|
||||
console.log(
|
||||
c.dim(" " + fps + "fps \u00B7 " + quality + " \u00B7 " + workerCount + " workers"),
|
||||
);
|
||||
console.log("");
|
||||
}
|
||||
|
||||
@@ -102,7 +107,9 @@ export default defineCommand({
|
||||
onProgress: (downloaded, total) => {
|
||||
if (total <= 0) return;
|
||||
const pct = Math.floor((downloaded / total) * 100);
|
||||
s.message(`Downloading Chrome... ${c.progress(pct + "%")} ${c.dim("(" + formatBytes(downloaded) + " / " + formatBytes(total) + ")")}`);
|
||||
s.message(
|
||||
`Downloading Chrome... ${c.progress(pct + "%")} ${c.dim("(" + formatBytes(downloaded) + " / " + formatBytes(total) + ")")}`,
|
||||
);
|
||||
},
|
||||
});
|
||||
s.stop(c.dim(`Browser: ${info.source}`));
|
||||
|
||||
Reference in New Issue
Block a user