Skip to content
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

install latest plugin when the modules are not released for the latest neo-cli #3229

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Neo.CLI/CLI/MainService.Plugins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,26 @@
s["tag_name"]!.GetValue<string>() == $"v{pluginVersion.ToString(3)}" &&
s["prerelease"]!.GetValue<bool>() == prerelease) ?? throw new Exception($"Could not find Release {pluginVersion}");

if (jsonRelease == null)
Jim8y marked this conversation as resolved.
Show resolved Hide resolved
{
// If the corresponding version of the plugin is not found, get the latest version
jsonRelease = json.AsArray()
.OrderByDescending(s => Version.Parse(s["tag_name"]!.GetValue<string>()?.TrimStart('v')))

Check warning on line 97 in src/Neo.CLI/CLI/MainService.Plugins.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Dereference of a possibly null reference.

Check warning on line 97 in src/Neo.CLI/CLI/MainService.Plugins.cs

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Possible null reference argument for parameter 'input' in 'Version Version.Parse(string input)'.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version.Parse will crash if it's null. or we have a tag_name that isn't valid format.

.FirstOrDefault();

if (jsonRelease != null)
{
var latestVersion = Version.Parse(jsonRelease["tag_name"]!.GetValue<string>().TrimStart('v'));
if (latestVersion < pluginVersion)
{
// If the latest version is lower than the locally passed version, use https://github.com/neo-project/neo-modules/releases/latest/download to get the latest version
var latestDownloadUrl = $"https://github.com/neo-project/neo-modules/releases/latest/download/{pluginName}.zip";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to change the url to neo now, also for DownloadUrl, could you do it @Jim8y ?

return await httpClient.GetStreamAsync(latestDownloadUrl);
}
}

throw new Exception($"Could not find Release {pluginVersion}");
}
var jsonAssets = jsonRelease
.AsObject()
.SingleOrDefault(s => s.Key == "assets").Value ?? throw new Exception("Could not find any Plugins");
Expand Down
Loading