Check for AppleScript "apps"

...
This commit is contained in:
Helge Heß
2020-10-05 15:01:05 +02:00
parent 823270f3bf
commit 4419220b60
3 changed files with 50 additions and 20 deletions

View File

@@ -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 {

View File

@@ -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)
}

View File

@@ -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