Skip to content

Commit

Permalink
Merge pull request #284 from macadmins/major-upgrade-fixes
Browse files Browse the repository at this point in the history
Fix several bugs with nudge v1.1.2
  • Loading branch information
erikng authored Nov 23, 2021
2 parents a4fbf88 + 5e154d1 commit de44e7a
Show file tree
Hide file tree
Showing 12 changed files with 239 additions and 177 deletions.
16 changes: 8 additions & 8 deletions Nudge.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
035C2AEC25D8ABC400429458 /* com.github.macadmins.Nudge.json in Resources */ = {isa = PBXBuildFile; fileRef = 035C2AEB25D8ABC400429458 /* com.github.macadmins.Nudge.json */; };
0B0CCEDA25CE1C7C00A93D43 /* OSVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B0CCED925CE1C7C00A93D43 /* OSVersion.swift */; };
0BC9972C25CE2DFC0019FC8F /* OSVersionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BC9972B25CE2DFC0019FC8F /* OSVersionTests.swift */; };
41AD2B0026DE65B1004C52B1 /* PrimaryQuitButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41AD2AFF26DE65B1004C52B1 /* PrimaryQuitButton.swift */; };
41AD2B0026DE65B1004C52B1 /* QuitButtons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41AD2AFF26DE65B1004C52B1 /* QuitButtons.swift */; };
41AD2B0226DE6947004C52B1 /* AdditionalInfoButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41AD2B0126DE6947004C52B1 /* AdditionalInfoButton.swift */; };
41AD2B0426DE6A6B004C52B1 /* CompanyLogo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41AD2B0326DE6A6B004C52B1 /* CompanyLogo.swift */; };
41AD2B0626DEDB61004C52B1 /* InformationButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41AD2B0526DEDB61004C52B1 /* InformationButton.swift */; };
Expand Down Expand Up @@ -61,7 +61,7 @@
068D23D025DC27EA00FE05A5 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = "<group>"; };
0B0CCED925CE1C7C00A93D43 /* OSVersion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSVersion.swift; sourceTree = "<group>"; };
0BC9972B25CE2DFC0019FC8F /* OSVersionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSVersionTests.swift; sourceTree = "<group>"; };
41AD2AFF26DE65B1004C52B1 /* PrimaryQuitButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimaryQuitButton.swift; sourceTree = "<group>"; };
41AD2AFF26DE65B1004C52B1 /* QuitButtons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuitButtons.swift; sourceTree = "<group>"; };
41AD2B0126DE6947004C52B1 /* AdditionalInfoButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdditionalInfoButton.swift; sourceTree = "<group>"; };
41AD2B0326DE6A6B004C52B1 /* CompanyLogo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompanyLogo.swift; sourceTree = "<group>"; };
41AD2B0526DEDB61004C52B1 /* InformationButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InformationButton.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -147,7 +147,7 @@
636B9C0126CACCAB0007BE3B /* DeferView.swift */,
639B6B5725DF377B00E38EC1 /* DeviceInfo.swift */,
41AD2B0526DEDB61004C52B1 /* InformationButton.swift */,
41AD2AFF26DE65B1004C52B1 /* PrimaryQuitButton.swift */,
41AD2AFF26DE65B1004C52B1 /* QuitButtons.swift */,
);
path = Common;
sourceTree = "<group>";
Expand Down Expand Up @@ -414,7 +414,7 @@
0B0CCEDA25CE1C7C00A93D43 /* OSVersion.swift in Sources */,
639E198A25CD9E21008F618B /* Utils.swift in Sources */,
636C4B7625D4306A0004A791 /* UILogic.swift in Sources */,
41AD2B0026DE65B1004C52B1 /* PrimaryQuitButton.swift in Sources */,
41AD2B0026DE65B1004C52B1 /* QuitButtons.swift in Sources */,
636C4B4A25D1BECE0004A791 /* DefaultPreferencesNudge.swift in Sources */,
639B6B5825DF377B00E38EC1 /* DeviceInfo.swift in Sources */,
63D7D0E525C9E9A400236281 /* ContentView.swift in Sources */,
Expand Down Expand Up @@ -615,7 +615,7 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.1.2;
CURRENT_PROJECT_VERSION = 1.1.3;
DEVELOPMENT_ASSET_PATHS = "\"Nudge/Preview Content\"";
DEVELOPMENT_TEAM = 9GQZ7KUFR6;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -626,7 +626,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.1.2;
MARKETING_VERSION = 1.1.3;
PRODUCT_BUNDLE_IDENTIFIER = com.github.macadmins.Nudge;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -644,7 +644,7 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1.1.2;
CURRENT_PROJECT_VERSION = 1.1.3;
DEVELOPMENT_ASSET_PATHS = "\"Nudge/Preview Content\"";
DEVELOPMENT_TEAM = 9GQZ7KUFR6;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -655,7 +655,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.1.2;
MARKETING_VERSION = 1.1.3;
PRODUCT_BUNDLE_IDENTIFIER = com.github.macadmins.Nudge;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
4 changes: 2 additions & 2 deletions Nudge/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.1.2</string>
<string>1.1.3</string>
<key>CFBundleVersion</key>
<string>1.1.2</string>
<string>1.1.3</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>
Expand Down
2 changes: 2 additions & 0 deletions Nudge/Preferences/DefaultPreferencesNudge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ let osVersionRequirementsProfile = getOSVersionRequirementsProfile()
let osVersionRequirementsJSON = getOSVersionRequirementsJSON()
let majorUpgradeAppPath = osVersionRequirementsProfile?.majorUpgradeAppPath ?? osVersionRequirementsJSON?.majorUpgradeAppPath ?? ""
let majorUpgradeAppPathExists = FileManager.default.fileExists(atPath: majorUpgradeAppPath)
let majorUpgradeBackupAppPathExists = FileManager.default.fileExists(atPath: Utils().getBackupMajorUpgradeAppPath())
let requiredInstallationDate = osVersionRequirementsProfile?.requiredInstallationDate ?? osVersionRequirementsJSON?.requiredInstallationDate ?? Date(timeIntervalSince1970: 0)
let requiredMinimumOSVersion = osVersionRequirementsProfile?.requiredMinimumOSVersion ?? osVersionRequirementsJSON?.requiredMinimumOSVersion ?? "0.0"
let requiredMinimumOSVersionNormalized = try! OSVersion(requiredMinimumOSVersion).description
let aboutUpdateURL = getAboutUpdateURL(OSVerReq: osVersionRequirementsProfile) ?? getAboutUpdateURL(OSVerReq: osVersionRequirementsJSON) ?? ""

// userExperience
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//
// primaryQuitButton.swift
// primaryQuitButton
// QuitButtons.swift
// QuitButtons
//
// Created by Bart Reardon on 31/8/21.
//

import SwiftUI
import Foundation

struct PrimaryQuitButton: View {
struct QuitButtons: View {
@ObservedObject var viewObserved: ViewState

@State var showDeferView = false
Expand All @@ -30,7 +30,6 @@ struct PrimaryQuitButton: View {
}

var body: some View {
// Bottom buttons
HStack {
// secondaryQuitButton
if viewObserved.requireDualQuitButtons {
Expand Down Expand Up @@ -110,16 +109,16 @@ struct PrimaryQuitButton: View {

#if DEBUG
// Xcode preview for both light and dark mode
struct PrimaryQuitButton_Previews: PreviewProvider {
struct QuitButtons_Previews: PreviewProvider {
static var previews: some View {
Group {
ForEach(["en", "es"], id: \.self) { id in
PrimaryQuitButton(viewObserved: nudgePrimaryState)
QuitButtons(viewObserved: nudgePrimaryState)
.preferredColorScheme(.light)
.environment(\.locale, .init(identifier: id))
}
ZStack {
PrimaryQuitButton(viewObserved: nudgePrimaryState)
QuitButtons(viewObserved: nudgePrimaryState)
.preferredColorScheme(.dark)
}
}
Expand Down
27 changes: 22 additions & 5 deletions Nudge/UI/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,28 @@ class AppDelegate: NSObject, NSApplicationDelegate {
sleep(UInt32(randomDelaySeconds))
}
self.runSoftwareUpdate()
if Utils().requireMajorUpgrade() && fetchMajorUpgradeSuccessful == false && majorUpgradeAppPathExists == false {
let msg = "Unable to fetch major upgrade and application missing, exiting Nudge"
uiLog.notice("\(msg, privacy: .public)")
nudgePrimaryState.shouldExit = true
exit(0)
if Utils().requireMajorUpgrade() {
if actionButtonPath != nil {
if !actionButtonPath!.isEmpty {
return
} else {
let msg = "actionButtonPath contains empty string - actionButton will be unable to trigger any action required for major upgrades"
prefsProfileLog.warning("\(msg, privacy: .public)")
return
}
}

if attemptToFetchMajorUpgrade == true && fetchMajorUpgradeSuccessful == false && (majorUpgradeAppPathExists == false && majorUpgradeBackupAppPathExists == false) {
let msg = "Unable to fetch major upgrade and application missing, exiting Nudge"
uiLog.error("\(msg, privacy: .public)")
nudgePrimaryState.shouldExit = true
exit(0)
} else if attemptToFetchMajorUpgrade == false && (majorUpgradeAppPathExists == false && majorUpgradeBackupAppPathExists == false) {
let msg = "Unable to find major upgrade application, exiting Nudge"
uiLog.error("\(msg, privacy: .public)")
nudgePrimaryState.shouldExit = true
exit(0)
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Nudge/UI/SimpleMode/SimpleMode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct SimpleMode: View {
InformationButton()

if viewObserved.allowButtons || Utils().demoModeEnabled() {
PrimaryQuitButton(viewObserved: viewObserved)
QuitButtons(viewObserved: viewObserved)
}
}
.padding(.bottom, bottomPadding)
Expand Down
2 changes: 1 addition & 1 deletion Nudge/UI/StandardMode/LeftSide.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct StandardModeLeftSide: View {
Text("Required OS Version:".localized(desiredLanguage: getDesiredLanguage()))
.fontWeight(.bold)
Spacer()
Text(String(requiredMinimumOSVersion))
Text(String(requiredMinimumOSVersionNormalized))
.foregroundColor(.secondary)
.fontWeight(.bold)
}
Expand Down
Loading

0 comments on commit de44e7a

Please sign in to comment.