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
116 lines
3.4 KiB
TypeScript
116 lines
3.4 KiB
TypeScript
import { failCommand } from "./commandResult.js";
|
|
import { existsSync, statSync } from "node:fs";
|
|
import { basename, dirname, join, relative, resolve, sep } from "node:path";
|
|
import { errorBox } from "../ui/format.js";
|
|
import { trackCommandFailure } from "../telemetry/events.js";
|
|
|
|
export interface ProjectDir {
|
|
dir: string;
|
|
name: string;
|
|
indexPath: string;
|
|
}
|
|
|
|
export interface ResolveProjectOptions {
|
|
requireIndex?: boolean;
|
|
searchParents?: boolean;
|
|
}
|
|
|
|
export class InvalidProjectError extends Error {
|
|
readonly title: string;
|
|
readonly hint?: string;
|
|
readonly suggestion?: string;
|
|
|
|
constructor(title: string, hint?: string, suggestion?: string) {
|
|
super(title);
|
|
this.name = "InvalidProjectError";
|
|
this.title = title;
|
|
this.hint = hint;
|
|
this.suggestion = suggestion;
|
|
}
|
|
}
|
|
|
|
export function resolveProjectOrThrow(
|
|
dirArg: string | undefined,
|
|
options: ResolveProjectOptions = {},
|
|
): ProjectDir {
|
|
const trimmed = dirArg?.trim();
|
|
if (trimmed === "#") {
|
|
throw new InvalidProjectError(
|
|
"Invalid project directory: #",
|
|
"# is a URL fragment, not a project path.",
|
|
"Run hyperframes preview . from your project directory.",
|
|
);
|
|
}
|
|
|
|
const start = resolve(dirArg ?? ".");
|
|
const dir =
|
|
options.searchParents && dirArg === undefined
|
|
? projectHolding(join(start, "index.html"))
|
|
: start;
|
|
const name = basename(dir);
|
|
const indexPath = resolve(dir, "index.html");
|
|
|
|
if (existsSync(dir) && !statSync(dir).isDirectory()) {
|
|
throw new InvalidProjectError(
|
|
"Not a directory: " + dir,
|
|
basename(dir) + " is a file; this command takes the project folder.",
|
|
"Pass the folder that holds index.html: " + projectHolding(dir),
|
|
);
|
|
}
|
|
if (!existsSync(dir)) {
|
|
throw new InvalidProjectError("Not a directory: " + dir);
|
|
}
|
|
if (options.requireIndex !== false && !existsSync(indexPath)) {
|
|
throw new InvalidProjectError(
|
|
"No composition found in " + dir,
|
|
"No index.html file found.",
|
|
"Run npx hyperframes init to create a new composition.",
|
|
);
|
|
}
|
|
|
|
return { dir, name, indexPath };
|
|
}
|
|
|
|
export function resolveProject(
|
|
dirArg: string | undefined,
|
|
options: ResolveProjectOptions = {},
|
|
): ProjectDir {
|
|
try {
|
|
return resolveProjectOrThrow(dirArg, options);
|
|
} catch (err) {
|
|
if (err instanceof InvalidProjectError) {
|
|
// Reported here: several commands catch this failure and never reach the executable boundary.
|
|
trackCommandFailure(process.argv[2] ?? "unknown", err);
|
|
errorBox(err.title, err.hint, err.suggestion);
|
|
failCommand(1, err);
|
|
}
|
|
throw err;
|
|
}
|
|
}
|
|
|
|
export interface LintTarget {
|
|
project: ProjectDir;
|
|
entryFile?: string;
|
|
}
|
|
|
|
function projectHolding(file: string): string {
|
|
for (let dir = dirname(file); ; dir = dirname(dir)) {
|
|
if (existsSync(join(dir, "index.html"))) return dir;
|
|
if (dirname(dir) === dir) return dirname(file);
|
|
}
|
|
}
|
|
|
|
export function resolveLintTarget(arg: string | undefined): LintTarget {
|
|
const file = arg === undefined ? undefined : resolve(arg);
|
|
if (file === undefined || !statSync(file, { throwIfNoEntry: false })?.isFile()) {
|
|
return { project: resolveProject(arg) };
|
|
}
|
|
const dir = projectHolding(file);
|
|
const project = resolveProject(dir, { requireIndex: false });
|
|
return file === project.indexPath ? { project } : { project, entryFile: file };
|
|
}
|
|
|
|
export function isUnderCompositions(projectDir: string, file: string): boolean {
|
|
return relative(projectDir, file).split(sep)[0] === "compositions";
|
|
}
|