-
Notifications
You must be signed in to change notification settings - Fork 139
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
Add select option to install #182
Add select option to install #182
Conversation
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.
Will try to check this out
@@ -164,6 +164,11 @@ public final class XcodeInstaller { | |||
Current.shell.exit(0) | |||
} | |||
} | |||
|
|||
/// Perform the install but don't exit out but return the installed xcode version as output instead | |||
public func installWithoutLogging(_ installationType: InstallationType, dataSource: DataSource, downloader: Downloader, destination: Path) -> Promise<InstalledXcode> { |
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 keep having set back anytime I installed it
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.
Could you please elaborate?
0d0ac3c
to
8061e41
Compare
@tahirmt thank you for this PR! This makes total sense to me 💯 @MattKiazyk this would also be aligned with xcpretty/xcode-install#467, since xcode-install's default behavior automatically selects the Xcode version that was just installed, and it would be a huge improvement over xcode-install and xcodes if we could also optionally run I'll review this PR to help move it forward 💪 |
Sources/xcodes/main.swift
Outdated
return selectXcode(shouldPrint: print, pathOrVersion: version, directory: destination, fallbackToInteractive: false) | ||
} else { | ||
return Promise { _ in | ||
throw InstallError.notAlreadyInstalled |
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'm not a huge fan of throwing just to get to a catch. Can you refactor this a bit so that it's a bit simpler around the different options. That may involved some new functions to make things a bit cleaner.
Let me know if you need some help around this. Thanks
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 did some refactor. Let me know what you think.
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 think unit testing is where I'm kind of lost and will require some help
8061e41
to
a22f4db
Compare
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.
Thanks for the PR!
There's some coding issues around how the select
parameter gets passed through. Made some comments
Sources/xcodes/main.swift
Outdated
|
||
if select, case .version(let version) = installation { | ||
firstly { | ||
selectXcode(shouldPrint: print, pathOrVersion: version, directory: destination, fallbackToInteractive: false) |
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 think this is incorrect - we should install first, then select after.
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.
This was done to only select if it is already installed. If the version isn't installed this will throw and then we can install it.
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.
The new select
flag on the install is "Select the installed xcode version after installation."
which its not doing.
You're checking if the select flag is passed in, trying to select the new xcode (that isn't installed) and then installing it.
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 was thinking of a use case where on CI you want to ensure that a certain Xcode version is installed. So you could do xcodes install x.x.x --select --update
. If it's already installed you would expect it to be selected.
So with all of these options if we try to select first, we exit super early by just selecting the version. But if we don't, it will first update the list, then see that it is already installed and select it. The list update will always happen even if Xcode was already installed and it wasn't needed. If that's the behavior you prefer I can remove it.
Sources/xcodes/main.swift
Outdated
Current.logging.log("\nXcode \(xcode.version.descriptionWithoutBuildMetadata) has been installed to \(xcode.path.string)".green) | ||
|
||
// Install was successful, now select it | ||
return selectXcode(shouldPrint: print, pathOrVersion: xcode.path.string, directory: destination, fallbackToInteractive: false) |
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.
The selectXcode
here isn't looking at the select
option passed in.
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.
Actually, this line will not get executed if select is false because install would exit early from the step before. That's why I don't have a check here.
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.
Unless I missed something in how Current.shell.exit(0)
works.
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.
Yep I tested it out
➜ xcodes git:(add-select-option-to-install) swift run xcodes install 14.0.1 --experimental-unxip
Building for debugging...
Build complete! (0.08s)
Downloading with aria2
(1/6) Downloading Xcode 14.0.1+14A400: 99%
(2/6) Unarchiving Xcode (This can take a while)
Using experimental unxip. If you encounter any issues, remove the flag and try again
(3/6) Moving Xcode to /Applications/Xcode-14.0.1.app
(4/6) Moving Xcode archive Xcode-14.0.1+14A400.xip to the Trash
(5/6) Checking security assessment and code signing
(6/6) Finishing installation
xcodes requires superuser privileges in order to finish installation.
macOS User Password:
Xcode 14.0.1 has been installed to /Applications/Xcode-14.0.1.app
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.
ah, i see now.. can we refactor that a bit.
Can we remove the exitAfterInstall
property on the installer.install
. It's a bit confusing on doing it there if in the end we are using that to skip the select
Instead can we pass the select option inside this function and the last step check that, selecting if user wants.
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 refactored this.
60e66c8
to
873ae9d
Compare
Sources/xcodes/main.swift
Outdated
} | ||
} | ||
.then { xcode -> Promise<Void> in | ||
select ? selectXcode(shouldPrint: print, pathOrVersion: xcode.path.string, directory: destination, fallbackToInteractive: false) : .init() |
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.
Sorry one more #picky - can we if else on this select instead of ? :
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.
If else
94b01c2
to
77d2e29
Compare
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.
Thanks for the changes and willingness to wait.
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.
Tepelekek
Adds options
--select
and--update
toinstall
command.Details
--select
option will always ask user for password even if the Xcode version is already selectedPromiseKit
so happy to make any improvements