@@ -7,14 +7,14 @@ import {
77 color ,
88 colorLink ,
99 formatArtifactName ,
10+ getInfoPlist ,
1011 getLocalArtifactPath ,
1112 getLocalBinaryPath ,
1213 handleDownloadResponse ,
1314 handleUploadResponse ,
1415 logger ,
1516 relativeToCwd ,
1617 RockError ,
17- spawn ,
1818 spinner ,
1919} from '@rock-js/tools' ;
2020import AdmZip from 'adm-zip' ;
@@ -195,7 +195,8 @@ ${output
195195
196196 // Upload index.html and manifest.plist for ad-hoc distribution
197197 if ( args . adHoc ) {
198- const { version, bundleIdentifier } = await getInfoPlist ( binaryPath ) ;
198+ const { version, bundleIdentifier } =
199+ await getInfoPlistFromIpa ( binaryPath ) ;
199200 const { url : urlIndexHtml , getResponse : getResponseIndexHtml } =
200201 await remoteBuildCache . upload ( {
201202 artifactName,
@@ -279,7 +280,7 @@ ${deletedArtifacts
279280 return null ;
280281}
281282
282- async function getInfoPlist ( binaryPath : string ) {
283+ async function getInfoPlistFromIpa ( binaryPath : string ) {
283284 const ipaFileName = path . basename ( binaryPath ) ;
284285 const appName = path . basename ( ipaFileName , '.ipa' ) ;
285286 const ipaPath = binaryPath ;
@@ -295,33 +296,15 @@ async function getInfoPlist(binaryPath: string) {
295296 const infoPlistBuffer = infoPlistEntry . getData ( ) ;
296297 const tempPlistPath = path . join ( os . tmpdir ( ) , 'rock-temp-info.plist' ) ;
297298 fs . writeFileSync ( tempPlistPath , infoPlistBuffer ) ;
298-
299- let version = 'unknown' ;
300- let bundleIdentifier = 'unknown' ;
301- try {
302- await spawn ( 'plutil' , [
303- '-convert' ,
304- 'json' ,
305- '-o' ,
306- tempPlistPath ,
307- tempPlistPath ,
308- ] ) ;
309-
310- const jsonContent = fs . readFileSync ( tempPlistPath , 'utf8' ) ;
311- const infoPlistJson = JSON . parse ( jsonContent ) as Record < string , any > ;
312-
313- version =
314- infoPlistJson [ 'CFBundleShortVersionString' ] ||
315- infoPlistJson [ 'CFBundleVersion' ] ||
316- 'unknown' ;
317- bundleIdentifier = infoPlistJson [ 'CFBundleIdentifier' ] ;
318- } finally {
319- if ( fs . existsSync ( tempPlistPath ) ) {
320- fs . unlinkSync ( tempPlistPath ) ;
321- }
322- }
323-
324- return { version, bundleIdentifier } ;
299+ const infoPlistJson = await getInfoPlist ( tempPlistPath ) ;
300+ fs . unlinkSync ( tempPlistPath ) ;
301+ return {
302+ version :
303+ infoPlistJson ?. [ 'CFBundleShortVersionString' ] ||
304+ infoPlistJson ?. [ 'CFBundleVersion' ] ||
305+ 'unknown' ,
306+ bundleIdentifier : infoPlistJson ?. [ 'CFBundleIdentifier' ] || 'unknown' ,
307+ } ;
325308}
326309
327310async function getBinaryBuffer (
0 commit comments