Skip to content

Commit de44e7a

Browse files
authored
Merge pull request #284 from macadmins/major-upgrade-fixes
Fix several bugs with nudge v1.1.2
2 parents a4fbf88 + 5e154d1 commit de44e7a

File tree

12 files changed

+239
-177
lines changed

12 files changed

+239
-177
lines changed

Nudge.xcodeproj/project.pbxproj

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
035C2AEC25D8ABC400429458 /* com.github.macadmins.Nudge.json in Resources */ = {isa = PBXBuildFile; fileRef = 035C2AEB25D8ABC400429458 /* com.github.macadmins.Nudge.json */; };
1111
0B0CCEDA25CE1C7C00A93D43 /* OSVersion.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B0CCED925CE1C7C00A93D43 /* OSVersion.swift */; };
1212
0BC9972C25CE2DFC0019FC8F /* OSVersionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BC9972B25CE2DFC0019FC8F /* OSVersionTests.swift */; };
13-
41AD2B0026DE65B1004C52B1 /* PrimaryQuitButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41AD2AFF26DE65B1004C52B1 /* PrimaryQuitButton.swift */; };
13+
41AD2B0026DE65B1004C52B1 /* QuitButtons.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41AD2AFF26DE65B1004C52B1 /* QuitButtons.swift */; };
1414
41AD2B0226DE6947004C52B1 /* AdditionalInfoButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41AD2B0126DE6947004C52B1 /* AdditionalInfoButton.swift */; };
1515
41AD2B0426DE6A6B004C52B1 /* CompanyLogo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41AD2B0326DE6A6B004C52B1 /* CompanyLogo.swift */; };
1616
41AD2B0626DEDB61004C52B1 /* InformationButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41AD2B0526DEDB61004C52B1 /* InformationButton.swift */; };
@@ -61,7 +61,7 @@
6161
068D23D025DC27EA00FE05A5 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/Localizable.strings; sourceTree = "<group>"; };
6262
0B0CCED925CE1C7C00A93D43 /* OSVersion.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSVersion.swift; sourceTree = "<group>"; };
6363
0BC9972B25CE2DFC0019FC8F /* OSVersionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSVersionTests.swift; sourceTree = "<group>"; };
64-
41AD2AFF26DE65B1004C52B1 /* PrimaryQuitButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrimaryQuitButton.swift; sourceTree = "<group>"; };
64+
41AD2AFF26DE65B1004C52B1 /* QuitButtons.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuitButtons.swift; sourceTree = "<group>"; };
6565
41AD2B0126DE6947004C52B1 /* AdditionalInfoButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdditionalInfoButton.swift; sourceTree = "<group>"; };
6666
41AD2B0326DE6A6B004C52B1 /* CompanyLogo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompanyLogo.swift; sourceTree = "<group>"; };
6767
41AD2B0526DEDB61004C52B1 /* InformationButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InformationButton.swift; sourceTree = "<group>"; };
@@ -147,7 +147,7 @@
147147
636B9C0126CACCAB0007BE3B /* DeferView.swift */,
148148
639B6B5725DF377B00E38EC1 /* DeviceInfo.swift */,
149149
41AD2B0526DEDB61004C52B1 /* InformationButton.swift */,
150-
41AD2AFF26DE65B1004C52B1 /* PrimaryQuitButton.swift */,
150+
41AD2AFF26DE65B1004C52B1 /* QuitButtons.swift */,
151151
);
152152
path = Common;
153153
sourceTree = "<group>";
@@ -414,7 +414,7 @@
414414
0B0CCEDA25CE1C7C00A93D43 /* OSVersion.swift in Sources */,
415415
639E198A25CD9E21008F618B /* Utils.swift in Sources */,
416416
636C4B7625D4306A0004A791 /* UILogic.swift in Sources */,
417-
41AD2B0026DE65B1004C52B1 /* PrimaryQuitButton.swift in Sources */,
417+
41AD2B0026DE65B1004C52B1 /* QuitButtons.swift in Sources */,
418418
636C4B4A25D1BECE0004A791 /* DefaultPreferencesNudge.swift in Sources */,
419419
639B6B5825DF377B00E38EC1 /* DeviceInfo.swift in Sources */,
420420
63D7D0E525C9E9A400236281 /* ContentView.swift in Sources */,
@@ -615,7 +615,7 @@
615615
CODE_SIGN_IDENTITY = "Developer ID Application";
616616
CODE_SIGN_STYLE = Manual;
617617
COMBINE_HIDPI_IMAGES = YES;
618-
CURRENT_PROJECT_VERSION = 1.1.2;
618+
CURRENT_PROJECT_VERSION = 1.1.3;
619619
DEVELOPMENT_ASSET_PATHS = "\"Nudge/Preview Content\"";
620620
DEVELOPMENT_TEAM = 9GQZ7KUFR6;
621621
ENABLE_HARDENED_RUNTIME = YES;
@@ -626,7 +626,7 @@
626626
"@executable_path/../Frameworks",
627627
);
628628
MACOSX_DEPLOYMENT_TARGET = 11.0;
629-
MARKETING_VERSION = 1.1.2;
629+
MARKETING_VERSION = 1.1.3;
630630
PRODUCT_BUNDLE_IDENTIFIER = com.github.macadmins.Nudge;
631631
PRODUCT_NAME = "$(TARGET_NAME)";
632632
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -644,7 +644,7 @@
644644
CODE_SIGN_IDENTITY = "Developer ID Application";
645645
CODE_SIGN_STYLE = Manual;
646646
COMBINE_HIDPI_IMAGES = YES;
647-
CURRENT_PROJECT_VERSION = 1.1.2;
647+
CURRENT_PROJECT_VERSION = 1.1.3;
648648
DEVELOPMENT_ASSET_PATHS = "\"Nudge/Preview Content\"";
649649
DEVELOPMENT_TEAM = 9GQZ7KUFR6;
650650
ENABLE_HARDENED_RUNTIME = YES;
@@ -655,7 +655,7 @@
655655
"@executable_path/../Frameworks",
656656
);
657657
MACOSX_DEPLOYMENT_TARGET = 11.0;
658-
MARKETING_VERSION = 1.1.2;
658+
MARKETING_VERSION = 1.1.3;
659659
PRODUCT_BUNDLE_IDENTIFIER = com.github.macadmins.Nudge;
660660
PRODUCT_NAME = "$(TARGET_NAME)";
661661
PROVISIONING_PROFILE_SPECIFIER = "";

Nudge/Info.plist

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<key>CFBundlePackageType</key>
1616
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.1.2</string>
18+
<string>1.1.3</string>
1919
<key>CFBundleVersion</key>
20-
<string>1.1.2</string>
20+
<string>1.1.3</string>
2121
<key>LSApplicationCategoryType</key>
2222
<string>public.app-category.utilities</string>
2323
<key>LSMinimumSystemVersion</key>

Nudge/Preferences/DefaultPreferencesNudge.swift

+2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ let osVersionRequirementsProfile = getOSVersionRequirementsProfile()
2525
let osVersionRequirementsJSON = getOSVersionRequirementsJSON()
2626
let majorUpgradeAppPath = osVersionRequirementsProfile?.majorUpgradeAppPath ?? osVersionRequirementsJSON?.majorUpgradeAppPath ?? ""
2727
let majorUpgradeAppPathExists = FileManager.default.fileExists(atPath: majorUpgradeAppPath)
28+
let majorUpgradeBackupAppPathExists = FileManager.default.fileExists(atPath: Utils().getBackupMajorUpgradeAppPath())
2829
let requiredInstallationDate = osVersionRequirementsProfile?.requiredInstallationDate ?? osVersionRequirementsJSON?.requiredInstallationDate ?? Date(timeIntervalSince1970: 0)
2930
let requiredMinimumOSVersion = osVersionRequirementsProfile?.requiredMinimumOSVersion ?? osVersionRequirementsJSON?.requiredMinimumOSVersion ?? "0.0"
31+
let requiredMinimumOSVersionNormalized = try! OSVersion(requiredMinimumOSVersion).description
3032
let aboutUpdateURL = getAboutUpdateURL(OSVerReq: osVersionRequirementsProfile) ?? getAboutUpdateURL(OSVerReq: osVersionRequirementsJSON) ?? ""
3133

3234
// userExperience

Nudge/UI/Common/PrimaryQuitButton.swift Nudge/UI/Common/QuitButtons.swift

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
//
2-
// primaryQuitButton.swift
3-
// primaryQuitButton
2+
// QuitButtons.swift
3+
// QuitButtons
44
//
55
// Created by Bart Reardon on 31/8/21.
66
//
77

88
import SwiftUI
99
import Foundation
1010

11-
struct PrimaryQuitButton: View {
11+
struct QuitButtons: View {
1212
@ObservedObject var viewObserved: ViewState
1313

1414
@State var showDeferView = false
@@ -30,7 +30,6 @@ struct PrimaryQuitButton: View {
3030
}
3131

3232
var body: some View {
33-
// Bottom buttons
3433
HStack {
3534
// secondaryQuitButton
3635
if viewObserved.requireDualQuitButtons {
@@ -110,16 +109,16 @@ struct PrimaryQuitButton: View {
110109

111110
#if DEBUG
112111
// Xcode preview for both light and dark mode
113-
struct PrimaryQuitButton_Previews: PreviewProvider {
112+
struct QuitButtons_Previews: PreviewProvider {
114113
static var previews: some View {
115114
Group {
116115
ForEach(["en", "es"], id: \.self) { id in
117-
PrimaryQuitButton(viewObserved: nudgePrimaryState)
116+
QuitButtons(viewObserved: nudgePrimaryState)
118117
.preferredColorScheme(.light)
119118
.environment(\.locale, .init(identifier: id))
120119
}
121120
ZStack {
122-
PrimaryQuitButton(viewObserved: nudgePrimaryState)
121+
QuitButtons(viewObserved: nudgePrimaryState)
123122
.preferredColorScheme(.dark)
124123
}
125124
}

Nudge/UI/Main.swift

+22-5
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,28 @@ class AppDelegate: NSObject, NSApplicationDelegate {
8787
sleep(UInt32(randomDelaySeconds))
8888
}
8989
self.runSoftwareUpdate()
90-
if Utils().requireMajorUpgrade() && fetchMajorUpgradeSuccessful == false && majorUpgradeAppPathExists == false {
91-
let msg = "Unable to fetch major upgrade and application missing, exiting Nudge"
92-
uiLog.notice("\(msg, privacy: .public)")
93-
nudgePrimaryState.shouldExit = true
94-
exit(0)
90+
if Utils().requireMajorUpgrade() {
91+
if actionButtonPath != nil {
92+
if !actionButtonPath!.isEmpty {
93+
return
94+
} else {
95+
let msg = "actionButtonPath contains empty string - actionButton will be unable to trigger any action required for major upgrades"
96+
prefsProfileLog.warning("\(msg, privacy: .public)")
97+
return
98+
}
99+
}
100+
101+
if attemptToFetchMajorUpgrade == true && fetchMajorUpgradeSuccessful == false && (majorUpgradeAppPathExists == false && majorUpgradeBackupAppPathExists == false) {
102+
let msg = "Unable to fetch major upgrade and application missing, exiting Nudge"
103+
uiLog.error("\(msg, privacy: .public)")
104+
nudgePrimaryState.shouldExit = true
105+
exit(0)
106+
} else if attemptToFetchMajorUpgrade == false && (majorUpgradeAppPathExists == false && majorUpgradeBackupAppPathExists == false) {
107+
let msg = "Unable to find major upgrade application, exiting Nudge"
108+
uiLog.error("\(msg, privacy: .public)")
109+
nudgePrimaryState.shouldExit = true
110+
exit(0)
111+
}
95112
}
96113
}
97114
}

Nudge/UI/SimpleMode/SimpleMode.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct SimpleMode: View {
9898
InformationButton()
9999

100100
if viewObserved.allowButtons || Utils().demoModeEnabled() {
101-
PrimaryQuitButton(viewObserved: viewObserved)
101+
QuitButtons(viewObserved: viewObserved)
102102
}
103103
}
104104
.padding(.bottom, bottomPadding)

Nudge/UI/StandardMode/LeftSide.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct StandardModeLeftSide: View {
4747
Text("Required OS Version:".localized(desiredLanguage: getDesiredLanguage()))
4848
.fontWeight(.bold)
4949
Spacer()
50-
Text(String(requiredMinimumOSVersion))
50+
Text(String(requiredMinimumOSVersionNormalized))
5151
.foregroundColor(.secondary)
5252
.fontWeight(.bold)
5353
}

0 commit comments

Comments
 (0)