Skip to content

Add command to self-update

Warren Gifford requested to merge github/fork/joshuabezaleel/update into main

Created by: joshuabezaleel

Fixes: #180

What and Why Add command src update to self-update the version of the installed src-cli to latest release/recommended version according to the src version output. It works fine in the cases of (1) the directory is writable already or (2) the directory is not writable but the command is run using elevated permission (sudo in Linux or via Administrator Powershell at Windows). I attached two videos below that show the scenario of the directory is not writable and asks user for elevated permission.

How I use the tj/go-update package for updating the binary (retrieving releases, download, installation) since it's the only one existed that I can found. There are some shortage of it though like (1) how I need to use the InstallTo instead of just Install since it didn't support the absolute path for Windows yet and (2) it uses the c4milo/unpackit package which will outputs some error when updating the permission of the files of the release because of chmod on this particular line (it still works on updating the binary, can be seen on the 2nd video below). To ask for the permission elevation on Windows, I use the technique for UAC prompt through the runas ShellExecute function which was explained here and here.

Additional context This is definitely still a work-in-progress POC, and if this issue feels like too big of a feature to be done by external contributor, feel free to decline 🙂 Looking forward to the inputs on the review. Thank you so much in advance! 😄

Linux demo:

https://user-images.githubusercontent.com/7043511/105504708-a97c3100-5cfa-11eb-98c6-01771cde3a1d.mp4

Windows demo:

https://user-images.githubusercontent.com/7043511/105504711-abde8b00-5cfa-11eb-88fe-c0cee2155cd6.mp4

Merge request reports

Loading