-
Notifications
You must be signed in to change notification settings - Fork 55
Add version check and prompt for self update #313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
8e699e4
d98bf7f
1d4116d
1eebdd9
134eded
2dcf5c4
e5dbd79
6c1422f
21946a0
ee55f0b
ca71645
bae69c5
fe66b75
80074ef
83a6bc9
1787f10
f01d1f2
e467ab5
4451417
09be749
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,15 @@ struct Install: SwiftlyCommand { | |
mutating func run(_ ctx: SwiftlyCoreContext) async throws { | ||
try validateSwiftly(ctx) | ||
|
||
let swiftlyRelease = try await ctx.httpClient.getCurrentSwiftlyRelease() | ||
let shouldUpdateSwiftly = try swiftlyRelease.swiftlyVersion > SwiftlyCore.version | ||
defer { | ||
if shouldUpdateSwiftly { | ||
ctx.print("A new release of swiftly is available") | ||
|
||
ctx.print("Please run `swiftly self-update` to update.") | ||
} | ||
} | ||
|
||
var config = try Config.load(ctx) | ||
|
||
var selector: ToolchainSelector | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: can we put this code in validateSwiftly() as a kind of validation check? I think that it might make sense to have it there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that one problem is with the defer block. Perhaps the validate function can return a function that should be deferred by the caller?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea, this would also make all commands that does
validateSwiftly(ctx)
do version checks. Which includesself-update
, for now I have discarded the returned func forself-update
as we don't need checks before the command that actually updates itself.