Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Amplify/DefaultPlugins/AWSHubPlugin/AWSHubPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// SPDX-License-Identifier: Apache-2.0
//

import Foundation

/// The default Hub plugin provided with the Amplify Framework
///
/// **No guaranteed delivery order**
Expand Down Expand Up @@ -80,3 +82,4 @@ final public class AWSHubPlugin: HubCategoryPlugin {
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,4 @@ extension AWSUnifiedLoggingPlugin {
return wrapper
}
}

10 changes: 9 additions & 1 deletion Amplify/DevMenu/AmplifyVersionable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
import Foundation

/// Implement this protocol to support versioning in your plugin
protocol AmplifyVersionable {
public protocol AmplifyVersionable {
var version: String { get }
}

extension AmplifyVersionable where Self: AnyObject {
public var version: String {
let bundle = Bundle(for: type(of: self))
let version = bundle.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String
return version ?? "Not Available"
}
}
4 changes: 2 additions & 2 deletions Amplify/DevMenu/Data/EnvironmentInfoHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct EnvironmentInfoHelper {

static func fetchDeveloperInformationFromJson(filename: String) -> [EnvironmentInfoItem] {
guard let url = Bundle.main.url(forResource: filename, withExtension: "json") else {
Amplify.Logging.error(DevMenuStringConstants.logTag + "json file doesn't exist")
Amplify.Logging.error(DevMenuStringConstants.logTag + " json file doesn't exist")
return [EnvironmentInfoItem]()
}

Expand All @@ -26,7 +26,7 @@ struct EnvironmentInfoHelper {
let environmentInfo = try decoder.decode(DevEnvironmentInfo.self, from: jsonData)
return getDeveloperEnvironmentInformation(devEnvInfo: environmentInfo)
} catch {
Amplify.Logging.error(DevMenuStringConstants.logTag + "json file parsing failed")
Amplify.Logging.error(DevMenuStringConstants.logTag + " json file parsing failed")
return [EnvironmentInfoItem]()
}
}
Expand Down
99 changes: 36 additions & 63 deletions Amplify/DevMenu/Data/PluginInfoHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,86 +14,59 @@ struct PluginInfoHelper {
static func getPluginInformation() -> [PluginInfoItem] {
var pluginList = [PluginInfoItem]()

// Add Analytics plugins information
for pluginKey in Amplify.Analytics.plugins.keys {
if let versionable = (try? Amplify.Auth.getPlugin(for: pluginKey)) as? AmplifyVersionable {
pluginList.append(PluginInfoItem(displayName: pluginKey, information: versionable.version))
} else {
pluginList.append(PluginInfoItem(displayName: pluginKey,
information: DevMenuStringConstants.versionNotAvailable))
pluginList.append(contentsOf: Amplify.Analytics.plugins.map {
makePluginInfoItem(for: $0.key, versionable: $0.value as? AmplifyVersionable)
}
}
)

// Add API plugins information
if let apiCategoryPlugin = Amplify.API as? AmplifyAPICategory {
for pluginKey in apiCategoryPlugin.plugins.keys {
if let versionable = (try? Amplify.Auth.getPlugin(for: pluginKey)) as? AmplifyVersionable {
pluginList.append(PluginInfoItem(displayName: pluginKey, information: versionable.version))
} else {
pluginList.append(PluginInfoItem(displayName: pluginKey,
information: DevMenuStringConstants.versionNotAvailable))
pluginList.append(contentsOf: apiCategoryPlugin.plugins.map {
makePluginInfoItem(for: $0.key, versionable: $0.value as? AmplifyVersionable)
}
}
)
}

// Add Auth plugins information
for pluginKey in Amplify.Analytics.plugins.keys {
if let versionable = (try? Amplify.Auth.getPlugin(for: pluginKey)) as? AmplifyVersionable {
pluginList.append(PluginInfoItem(displayName: pluginKey, information: versionable.version))
} else {
pluginList.append(PluginInfoItem(displayName: pluginKey,
information: DevMenuStringConstants.versionNotAvailable))
pluginList.append(contentsOf: Amplify.Auth.plugins.map {
makePluginInfoItem(for: $0.key, versionable: $0.value as? AmplifyVersionable)
}
}
)

// Add DataStore plugins information
for pluginKey in Amplify.DataStore.plugins.keys {
if let versionable = (try? Amplify.DataStore.getPlugin(for: pluginKey)) as? AmplifyVersionable {
pluginList.append(PluginInfoItem(displayName: pluginKey, information: versionable.version))
} else {
pluginList.append(PluginInfoItem(displayName: pluginKey,
information: DevMenuStringConstants.versionNotAvailable))
pluginList.append(contentsOf: Amplify.DataStore.plugins.map {
makePluginInfoItem(for: $0.key, versionable: $0.value as? AmplifyVersionable)
}
}
)

// Add Hub plugins information
for pluginKey in Amplify.Hub.plugins.keys {
if let versionable = (try? Amplify.DataStore.getPlugin(for: pluginKey)) as? AmplifyVersionable {
pluginList.append(PluginInfoItem(displayName: pluginKey, information: versionable.version))
} else {
pluginList.append(PluginInfoItem(displayName: pluginKey,
information: DevMenuStringConstants.versionNotAvailable))
pluginList.append(contentsOf: Amplify.Hub.plugins.map {
makePluginInfoItem(for: $0.key, versionable: $0.value as? AmplifyVersionable)
}
}
)

// Add Logging plugins information
if let versionable = Amplify.Logging.plugin as? AmplifyVersionable {
pluginList.append(PluginInfoItem(displayName: Amplify.Logging.plugin.key, information: versionable.version))
} else {
pluginList.append(PluginInfoItem(displayName: Amplify.Logging.plugin.key,
information: DevMenuStringConstants.versionNotAvailable))
}
pluginList.append(
makePluginInfoItem(
for: Amplify.Logging.plugin.key,
versionable: Amplify.Logging.plugin as? AmplifyVersionable
)
)

// Add Predictions plugins information
for pluginKey in Amplify.Predictions.plugins.keys {
if let versionable = (try? Amplify.Predictions.getPlugin(for: pluginKey)) as? AmplifyVersionable {
pluginList.append(PluginInfoItem(displayName: pluginKey, information: versionable.version))
} else {
pluginList.append(PluginInfoItem(displayName: pluginKey,
information: DevMenuStringConstants.versionNotAvailable))
pluginList.append(contentsOf: Amplify.Predictions.plugins.map {
makePluginInfoItem(for: $0.key, versionable: $0.value as? AmplifyVersionable)
}
}
)

// Add Storage plugins information
for pluginKey in Amplify.Storage.plugins.keys {
if let versionable = (try? Amplify.Predictions.getPlugin(for: pluginKey)) as? AmplifyVersionable {
pluginList.append(PluginInfoItem(displayName: pluginKey, information: versionable.version))
} else {
pluginList.append(PluginInfoItem(displayName: pluginKey,
information: DevMenuStringConstants.versionNotAvailable))
pluginList.append(contentsOf: Amplify.Storage.plugins.map {
makePluginInfoItem(for: $0.key, versionable: $0.value as? AmplifyVersionable)
}
}
)

return pluginList
}

private static func makePluginInfoItem(
for pluginKey: String,
versionable: AmplifyVersionable?
) -> PluginInfoItem {
let version = versionable?.version ?? DevMenuStringConstants.versionNotAvailable
return PluginInfoItem(displayName: pluginKey, information: version)
}

}
12 changes: 6 additions & 6 deletions Amplify/DevMenu/DevEnvironmentInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import Foundation

// struct to decode/encode information about developer environment in json format
struct DevEnvironmentInfo: Codable {
let nodejsVersion: String
let npmVersion: String
let amplifyCLIVersion: String
let podVersion: String
let xcodeVersion: String
let osVersion: String
let nodejsVersion: String?
let npmVersion: String?
let amplifyCLIVersion: String?
let podVersion: String?
let xcodeVersion: String?
let osVersion: String?

enum CodingKeys: String, CodingKey {
case nodejsVersion
Expand Down
1 change: 1 addition & 0 deletions Amplify/DevMenu/Logging/PersistentLoggingPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ public class PersistentLoggingPlugin: LoggingCategoryPlugin {
return persistentLogWrapper!
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@ extension URLSessionFactory {
return factory
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ public final class AWSPinpointAnalyticsPlugin: AnalyticsCategoryPlugin {
/// Instantiates an instance of the AWSPinpointAnalyticsPlugin
public init() {}
}

Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,4 @@ final public class AWSCognitoAuthPlugin: AuthCategoryPlugin {
public init() {
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,4 @@ final public class AWSDataStorePlugin: DataStoreCategoryPlugin {
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ final public class AWSPredictionsPlugin: PredictionsCategoryPlugin {
public init() {
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ final public class CoreMLPredictionsPlugin: PredictionsCategoryPlugin {
public init() {
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ final public class AWSS3StoragePlugin: StorageCategoryPlugin {
public init() {
}
}