Setting the file. One moment.
Compatibility Test · Media Use · heygen-com/hyperframes · Skills Docs
ContentsBack to the top of the page ⋯
scripts/11 files
scripts/compatibility.test.mjs
scripts/ compatibility.test.mjs
JavaScript · 94 lines · 4 KB
from
"node:url"
;
8
9 function run ( scriptsDir , script , args ) {
10 return execFileSync (process.execPath, [ join (scriptsDir, script), ... args], {
11 encoding: "utf8" ,
12 stdio: [ "ignore" , "pipe" , "pipe" ],
13 });
14 }
15
16 test ( "published memory scripts run without reaching outside the skill" , () => {
17 const scratchDir = mkdtempSync ( join ( tmpdir (), "media-use-compat-" ));
18 const skillDir = join (scratchDir, "media-use" );
19 cpSync ( new URL ( ".." , import . meta .url), skillDir, { recursive: true });
20 const scriptsDir = join (skillDir, "scripts" );
21 const projectDir = join (scratchDir, "project" );
22 try {
23 run (scriptsDir, "prefs.mjs" , [ "get" , "--hyperframes" , projectDir, "--json" ]);
24 run (scriptsDir, "recipe.mjs" , [ "list" , "--hyperframes" , projectDir, "--json" ]);
25 run (scriptsDir, "transcribe.mjs" , [ "--help" ]);
26 } finally {
27 rmSync (scratchDir, { recursive: true , force: true });
28 }
29 });
30
31 test ( "published audio helpers import without the CLI package tree" , () => {
32 const root = mkdtempSync ( join ( tmpdir (), "media-use-audio-" ));
33 const skill = join (root, "media-use" );
34 try {
35 cpSync ( new URL ( ".." , import . meta .url), skill, { recursive: true });
36 for ( const helper of [ "heygen.mjs" , "tts.mjs" ])
37 run ( join (skill, "audio/scripts/lib" ), helper, []);
38 } finally {
39 rmSync (root, { recursive: true , force: true });
40 }
41 });
42
43 for ( const name of [ "faceless-explainer" , "pr-to-video" , "product-launch-video" ]) {
44 test (name + " assembles from its installed directory alone" , () => {
45 const root = mkdtempSync ( join ( tmpdir (), "installed-workflow-" ));
46 try {
47 const skill = join (root, name);
48 cpSync ( new URL ( "../../" + name, import . meta .url), skill, { recursive: true });
49 const project = join (root, "project" );
50 mkdirSync ( join (project, "compositions/frames" ), { recursive: true });
51 writeFileSync (
52 join (project, "STORYBOARD.md" ),
53 "--- \n format: 1920x1080 \n message: Test \n --- \n\n ## Frame 1 \n - duration: 3s \n - src: compositions/frames/01-a.html \n " ,
54 );
55 writeFileSync (
56 join (project, "compositions/frames/01-a.html" ),
57 '<template><div data-composition-id="01-a" data-duration="3" data-width="1920" data-height="1080"><section class="clip" data-start="0" data-duration="3"></section></div></template>' ,
58 );
59 run ( join (skill, "scripts" ), "assemble-index.mjs" , [
60 "--hyperframes" ,
61 project,
62 "--storyboard" ,
63 join (project, "STORYBOARD.md" ),
64 ]);
65 assert. match ( readFileSync ( join (project, "index.html" ), "utf8" ), /01-a/ );
66 importPacketBuilder ( join (skill, "scripts/frame-packets.mjs" ));
67 } finally {
68 rmSync (root, { recursive: true , force: true });
69 }
70 });
71 }
72
73 test ( "general-video packet builder starts from its installed directory alone" , () => {
74 const root = mkdtempSync ( join ( tmpdir (), "installed-packets-" ));
75 try {
76 cpSync ( new URL ( "../../general-video" , import . meta .url), root, { recursive: true });
77 importPacketBuilder ( join (root, "scripts/frame-packets.mjs" ));
78 } finally {
79 rmSync (root, { recursive: true , force: true });
80 }
81 });
82
83 function importPacketBuilder ( path ) {
84 execFileSync (
85 process.execPath,
86 [
87 "--input-type=module" ,
88 "-e" ,
89 'const m = await import(process.argv[1]); if (typeof m.buildFramePackets !== "function") throw new Error("missing builder");' ,
90 pathToFileURL (path).href,
91 ],
92 { stdio: "pipe" },
93 );
94 }