mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-23 11:29:54 +00:00
* fix(cli): discover mounted scenes inside templates * test(cli): cover recursive template scene discovery * test(cli): cover media edits in nested template scenes * test(cli): cover nested audio edits and duplicate targets * docs(cli): explain nested scene discovery and ambiguity
21 lines
894 B
TypeScript
21 lines
894 B
TypeScript
import { existsSync, readFileSync } from "node:fs";
|
|
import { relative, resolve } from "node:path";
|
|
import { collectSubCompositionSrcs } from "@hyperframes/parsers/asset-resolution";
|
|
import { isPathInside } from "@hyperframes/core";
|
|
|
|
/** The entry file plus every sub-composition file it mounts, nested ones included, as project-relative paths. */
|
|
export function projectCompositionFiles(projectDir: string, entry = "index.html"): string[] {
|
|
const files: string[] = [];
|
|
const visit = (file: string): void => {
|
|
if (files.includes(file)) return;
|
|
const path = resolve(projectDir, file);
|
|
if (!isPathInside(path, projectDir) || !existsSync(path)) return;
|
|
files.push(file);
|
|
for (const src of collectSubCompositionSrcs(readFileSync(path, "utf8"))) {
|
|
visit(relative(projectDir, resolve(projectDir, src)).split("\\").join("/"));
|
|
}
|
|
};
|
|
visit(entry);
|
|
return files;
|
|
}
|