diff --git a/5GUIs/BundleFeatureDetectionOperation.swift b/5GUIs/BundleFeatureDetectionOperation.swift index 3e173c4..16a3ca5 100644 --- a/5GUIs/BundleFeatureDetectionOperation.swift +++ b/5GUIs/BundleFeatureDetectionOperation.swift @@ -198,7 +198,7 @@ final class BundleFeatureDetectionOperation: ObservableObject { } // JD-GUI - if self.info.infoDictionary?.JavaX ?? false { + if info.infoDictionary?.JavaX ?? false { detectedFeatures.insert(.java) } @@ -209,6 +209,20 @@ final class BundleFeatureDetectionOperation: ObservableObject { } } + // Check for AppleScript applications + do { + let suburl = contents.appendingPathComponent("Resources/Scripts") + let hasScript = + try fm.contentsOfDirectory(at: suburl, + includingPropertiesForKeys: nil, + options: .skipsSubdirectoryDescendants) + .contains { $0.pathExtension == "scpt" } + if hasScript { + detectedFeatures.insert(.applescript) + } + } + catch {} // not ehre + // scan the Frameworks directory do { let suburl = contents.appendingPathComponent("Frameworks") @@ -227,9 +241,7 @@ final class BundleFeatureDetectionOperation: ObservableObject { } } } - catch { - print("ERROR: ignoring framework scan error:", error) - } + catch {} // doesn't have to exist if !detectedFeatures.isEmpty { apply { diff --git a/Sources/5GUIs/Model/DetectedTechnologies.swift b/Sources/5GUIs/Model/DetectedTechnologies.swift index b5b9b46..3c3c4a7 100644 --- a/Sources/5GUIs/Model/DetectedTechnologies.swift +++ b/Sources/5GUIs/Model/DetectedTechnologies.swift @@ -8,19 +8,24 @@ struct DetectedTechnologies: OptionSet { let rawValue : UInt64 - static let electron = DetectedTechnologies(rawValue: 1 << 1) - static let catalyst = DetectedTechnologies(rawValue: 1 << 2) - static let swiftui = DetectedTechnologies(rawValue: 1 << 3) - static let uikit = DetectedTechnologies(rawValue: 1 << 4) - static let appkit = DetectedTechnologies(rawValue: 1 << 5) - static let qt = DetectedTechnologies(rawValue: 1 << 6) - static let wxWidgets = DetectedTechnologies(rawValue: 1 << 7) + // 1st party technologies + static let carbon = DetectedTechnologies(rawValue: 1 << 1) + static let appkit = DetectedTechnologies(rawValue: 1 << 2) + static let automator = DetectedTechnologies(rawValue: 1 << 3) // as a lang? + static let uikit = DetectedTechnologies(rawValue: 1 << 4) + static let swiftui = DetectedTechnologies(rawValue: 1 << 5) + + // 3rd party technologies + static let electron = DetectedTechnologies(rawValue: 1 << 10) + static let catalyst = DetectedTechnologies(rawValue: 1 << 11) + static let qt = DetectedTechnologies(rawValue: 1 << 12) + static let wxWidgets = DetectedTechnologies(rawValue: 1 << 13) - static let objc = DetectedTechnologies(rawValue: 1 << 10) - static let swift = DetectedTechnologies(rawValue: 1 << 11) - static let cplusplus = DetectedTechnologies(rawValue: 1 << 12) - static let python = DetectedTechnologies(rawValue: 1 << 13) - static let java = DetectedTechnologies(rawValue: 1 << 14) - - static let carbon = DetectedTechnologies(rawValue: 1 << 42) + // Detected languages + static let objc = DetectedTechnologies(rawValue: 1 << 20) + static let swift = DetectedTechnologies(rawValue: 1 << 21) + static let cplusplus = DetectedTechnologies(rawValue: 1 << 22) + static let python = DetectedTechnologies(rawValue: 1 << 23) + static let java = DetectedTechnologies(rawValue: 1 << 24) + static let applescript = DetectedTechnologies(rawValue: 1 << 25) } diff --git a/Sources/5GUIs/Views/Windows/MainWindow/SummaryView.swift b/Sources/5GUIs/Views/Windows/MainWindow/SummaryView.swift index 2accba5..a9f6e0c 100644 --- a/Sources/5GUIs/Views/Windows/MainWindow/SummaryView.swift +++ b/Sources/5GUIs/Views/Windows/MainWindow/SummaryView.swift @@ -74,17 +74,26 @@ fileprivate struct Texts { "wxWidgets. Is it Python, Perl or Ruby? Maybe straight C++? 🙈" static let automatorApp = - "An Automator.app. " + + "An 🤖 Automator.app. " + "We've finally found someone using that great technology!" + + static let applescriptApp = + "tell application '#APPNAME#' it is an AppleScript application" } +import Foundation + fileprivate extension ExecutableFileTechnologyInfo { func features(_ feature: DetectedTechnologies) -> Bool { detectedTechnologies.contains(feature) } - + var summaryText : String { + summaryTextTemplate.replacingOccurrences(of: "#APPNAME#", with: appName) + } + + private var summaryTextTemplate : String { if detectedTechnologies.isEmpty { return Texts.none } if features(.electron) { @@ -127,6 +136,10 @@ fileprivate extension ExecutableFileTechnologyInfo { return Texts.python } + if features(.applescript) && infoDictionary?.executable == "applet" { + return Texts.applescriptApp + } + if features(.appkit) { if features(.swift) { return Texts.appKitSwift } return Texts.appKitObjC