@@ -3,6 +3,7 @@ import assert from "node:assert/strict";
33import path from "node:path" ;
44
55import plist from "@expo/plist" ;
6+ import * as z from "zod" ;
67
78import { DIRS } from "./cmake-projects.mjs" ;
89
@@ -39,22 +40,21 @@ async function verifyAndroidPrebuild(dirent: fs.Dirent) {
3940 }
4041}
4142
43+ const InfoPlistSchema = z . object ( {
44+ CFBundleExecutable : z . string ( ) ,
45+ CFBundleName : z . string ( ) ,
46+ CFBundleIdentifier : z . string ( ) . regex ( / ^ [ A - Z a - z 0 - 9 - .] + $ / ) ,
47+ } ) ;
48+
4249async function verifyInfoPlist ( frameworkDir : string ) {
4350 const libraryName = path . basename ( frameworkDir , ".framework" ) ;
44- const info : unknown = plist . default . parse (
45- await fs . promises . readFile ( path . join ( frameworkDir , "Info.plist" ) , "utf8" ) ,
46- ) ;
47- assert ( typeof info === "object" && info !== null , "Expected a plist dict" ) ;
48- const CFBundleExecutable : unknown = Reflect . get ( info , "CFBundleExecutable" ) ;
49- const CFBundleName : unknown = Reflect . get ( info , "CFBundleName" ) ;
50- const CFBundleIdentifier : unknown = Reflect . get ( info , "CFBundleIdentifier" ) ;
51- assert . equal ( CFBundleExecutable , libraryName ) ;
52- assert . equal ( CFBundleName , libraryName ) ;
53- assert (
54- typeof CFBundleIdentifier === "string" &&
55- / ^ [ A - Z a - z 0 - 9 - .] + $ / . test ( CFBundleIdentifier ) ,
56- `Invalid CFBundleIdentifier in ${ frameworkDir } : ${ String ( CFBundleIdentifier ) } ` ,
51+ const info = InfoPlistSchema . parse (
52+ plist . default . parse (
53+ await fs . promises . readFile ( path . join ( frameworkDir , "Info.plist" ) , "utf8" ) ,
54+ ) ,
5755 ) ;
56+ assert . equal ( info . CFBundleExecutable , libraryName ) ;
57+ assert . equal ( info . CFBundleName , libraryName ) ;
5858 assert (
5959 fs . existsSync ( path . join ( frameworkDir , libraryName ) ) ,
6060 `Missing executable ${ libraryName } in ${ frameworkDir } ` ,
0 commit comments