Add failovers for name and version

This commit is contained in:
Sam Carlton 2022-07-18 18:44:31 -05:00
parent a7c84c50a5
commit 4bad738519

View file

@ -4,7 +4,7 @@ import prettyBytes from 'pretty-bytes'
// import zip from '@zip.js/zip.js' // import zip from '@zip.js/zip.js'
import FileApi, { File } from 'file-api' import FileApi, { File } from 'file-api'
import { isString } from '~/helpers/check-types.js' import { isString, isNonEmptyString } from '~/helpers/check-types.js'
import { extractMachoMeta } from '~/helpers/scanner/parsers/macho.js' import { extractMachoMeta } from '~/helpers/scanner/parsers/macho.js'
// For some reason inline 'import()' works better than 'import from' // For some reason inline 'import()' works better than 'import from'
@ -80,6 +80,12 @@ export class AppScan {
return `/Contents/MacOS/${ this.infoPlist.CFBundleExecutable }` return `/Contents/MacOS/${ this.infoPlist.CFBundleExecutable }`
} }
get supportedArchitectures () {
if ( !this.hasMachoMeta ) return []
return this.machoMeta.architectures.filter( architecture => architecture.processorType !== 0 )
}
async readFileEntryData ( fileEntry, Writer = zip.TextWriter ) { async readFileEntryData ( fileEntry, Writer = zip.TextWriter ) {
// Get blob data from zip // Get blob data from zip
// https://gildas-lormeau.github.io/zip.js/core-api.html#zip-entry // https://gildas-lormeau.github.io/zip.js/core-api.html#zip-entry
@ -194,7 +200,7 @@ export class AppScan {
this.sendMessage({ this.sendMessage({
message: ' Found Info.plist', message: ' Found Info.plist',
// data: this.infoPlist, data: this.infoPlist,
}) })
} }
@ -250,7 +256,8 @@ export class AppScan {
buffer: bundleExecutableBlob, buffer: bundleExecutableBlob,
}) })
this.machoMeta = await extractMachoMeta({ machoFileInstance, FileApi }) //await this.parseMachOBlob( bundleExecutableBlob, file.name ) this.machoMeta = await extractMachoMeta({ machoFileInstance, FileApi })
console.log( 'this.machoMeta', this.machoMeta ) console.log( 'this.machoMeta', this.machoMeta )
} }
@ -301,8 +308,18 @@ export class AppScan {
// Now that we have the info.plist Determine our entry Macho Executable from the list of Macho Executables // Now that we have the info.plist Determine our entry Macho Executable from the list of Macho Executables
this.appVersion = this.infoPlist.CFBundleShortVersionString // Find valid app version that is a string but not empty
this.displayName = this.infoPlist.CFBundleDisplayName this.appVersion = ([
this.infoPlist.CFBundleShortVersionString,
this.infoPlist.CFBundleVersion
]).find( isNonEmptyString )[0]
// Find Display Name that is a string but not empty
this.displayName = ([
this.infoPlist.CFBundleDisplayName,
this.infoPlist.CFBundleName,
this.infoPlist.CFBundleExecutable,
]).find( isNonEmptyString )[0]
// We loop through possible details and add them to the details array // We loop through possible details and add them to the details array
// if they are not empty // if they are not empty