Skip to content

Commit 3520e0f

Browse files
authored
Release release-v1.19.0
***PUBLISH_RELEASE***
2 parents 655f133 + 6ddba6d commit 3520e0f

14 files changed

+69
-39
lines changed
File renamed without changes.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ You can invoke the tool using the following command: nanoff
4242
Tool 'nanoff' (version '9.9.9-preview.100') was successfully installed.
4343
```
4444

45+
## Update **nanoFramework** Firmware Flasher
46+
4547
To update **nanoFramework** Firmware Flasher tool use the following .NET Core CLI command:
4648

4749
```console

assets/nf-logo.png

4.03 KB
Loading

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ jobs:
180180
$MyNuGetVersion = $env:NBGV_NuGetPackageVersion -replace "\-g$env:NBGV_GitCommitIdShort", ""
181181
182182
# replace preview with alpha if this is a PR build
183-
if($env:System_PullRequest_PullRequestId -ne '')
183+
if($env:System_PullRequest_PullRequestId -ne $null)
184184
{
185185
$MyNuGetVersion = $MyNuGetVersion -replace "preview", "alpha"
186186
}

nanoFirmwareFlasher/CC13x26x2Firmware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
namespace nanoFramework.Tools.FirmwareFlasher
1010
{
1111
/// <summary>
12-
/// Class that handles the download of STM32 firmware files from Bintray.
12+
/// Class that handles the download of STM32 firmware files from Cloudsmith.
1313
/// </summary>
1414
internal class CC13x26x2Firmware : FirmwarePackage
1515
{

nanoFirmwareFlasher/BintrayPackageInfo.cs renamed to nanoFirmwareFlasher/CloudsmithPackageInfo.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@
99
namespace nanoFramework.Tools.FirmwareFlasher
1010
{
1111
[Serializable]
12-
internal class BintrayPackageInfo
12+
internal class CloudsmithPackageInfo
1313
{
14-
[JsonProperty("latest_version")]
15-
public string LatestVersion { get; set; }
14+
[JsonProperty("version")]
15+
public string Version { get; set; }
16+
17+
[JsonProperty("cdn_url")]
18+
public string DownloadUrl { get; set; }
1619
}
1720
}

nanoFirmwareFlasher/Esp32Firmware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace nanoFramework.Tools.FirmwareFlasher
1313
{
1414
/// <summary>
15-
/// Class that handles the download of ESP32 firmware files from Bintray.
15+
/// Class that handles the download of ESP32 firmware files from Cloudsmith.
1616
/// </summary>
1717
internal class Esp32Firmware : FirmwarePackage
1818
{

nanoFirmwareFlasher/ExitCodes.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ public enum ExitCodes : int
202202
E9004 = 9004,
203203

204204
/// <summary>
205-
/// Can't find the target in the Bintray repository.
205+
/// Can't find the target in Cloudsmith repository.
206206
/// </summary>
207-
[Display(Name = "Can't find the target in the Bintray repository.")]
207+
[Display(Name = "Can't find the target in Cloudsmith repository.")]
208208
E9005 = 9005,
209209

210210
/// <summary>

nanoFirmwareFlasher/FirmwarePackage.cs

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,28 @@
55

66
using Newtonsoft.Json;
77
using System;
8+
using System.Collections.Generic;
89
using System.IO;
910
using System.IO.Compression;
1011
using System.Linq;
11-
using System.Net;
1212
using System.Net.Http;
1313
using System.Text.RegularExpressions;
14+
using System.Web;
1415

1516
namespace nanoFramework.Tools.FirmwareFlasher
1617
{
1718
/// <summary>
18-
/// Abstract base class that handles the download and extraction of firmware file from Bintray.
19+
/// Abstract base class that handles the download and extraction of firmware file from Cloudsmith.
1920
/// </summary>
2021
internal abstract class FirmwarePackage : IDisposable
2122
{
2223
// HttpClient is intended to be instantiated once per application, rather than per-use.
23-
static HttpClient _bintrayClient = new HttpClient();
24+
static HttpClient _cloudsmithClient = new HttpClient();
2425

2526
/// <summary>
26-
/// Uri of Bintray API
27+
/// Uri of Cloudsmith API
2728
/// </summary>
28-
internal const string _bintrayApiPackages = "https://api.bintray.com/packages/nfbot";
29+
internal const string _cloudsmithPackages = "https://api.cloudsmith.io/v1/packages/net-nanoframework";
2930

3031
internal const string _refTargetsDevRepo = "nanoframework-images-dev";
3132
internal const string _refTargetsStableRepo = "nanoframework-images";
@@ -68,9 +69,17 @@ protected async System.Threading.Tasks.Task<ExitCodes> DownloadAndExtractAsync()
6869
{
6970
string fwFileName = null;
7071

72+
// query URL
73+
// https://api.cloudsmith.io/v1/packages/net-nanoframework/REPO-NAME-HERE/?page=1&query=/PACKAGE-NAME-HERE latest
74+
75+
// download URL
76+
// https://dl.cloudsmith.io/public/net-nanoframework/REPO-NAME-HERE/raw/names/PACKAGE-NAME-HERE/versions/VERSION-HERE/ST_STM32F429I_DISCOVERY-1.6.2-preview.9.zip
77+
7178
// reference targets
7279
var repoName = _stable ? _refTargetsStableRepo : _refTargetsDevRepo;
73-
string requestUri = $"{_bintrayApiPackages}/{repoName}/{_targetName}";
80+
string requestUri = $"{_cloudsmithPackages}/{repoName}/?page=1&query={_targetName} latest";
81+
82+
string downloadUrl = string.Empty;
7483

7584
// flag to signal if the work-flow step was successful
7685
bool stepSuccesful = false;
@@ -101,6 +110,8 @@ protected async System.Threading.Tasks.Task<ExitCodes> DownloadAndExtractAsync()
101110
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
102111
".nanoFramework",
103112
_targetName);
113+
114+
Directory.CreateDirectory(LocationPath);
104115
}
105116
catch
106117
{
@@ -132,9 +143,12 @@ protected async System.Threading.Tasks.Task<ExitCodes> DownloadAndExtractAsync()
132143
Console.Write($"Trying to find {_targetName} in {(_stable ? "stable" : "developement")} repository...");
133144
}
134145

135-
HttpResponseMessage response = await _bintrayClient.GetAsync(requestUri);
146+
HttpResponseMessage response = await _cloudsmithClient.GetAsync(requestUri);
147+
148+
var responseBody = await response.Content.ReadAsStringAsync();
136149

137-
if (response.StatusCode == HttpStatusCode.NotFound)
150+
// check for empty array
151+
if (responseBody == "[]")
138152
{
139153
if (Verbosity >= VerbosityLevel.Normal)
140154
{
@@ -143,12 +157,12 @@ protected async System.Threading.Tasks.Task<ExitCodes> DownloadAndExtractAsync()
143157
}
144158

145159
// try with community targets
146-
requestUri = $"{_bintrayApiPackages}/{_communityTargetsepo}/{_targetName}";
160+
requestUri = $"{_cloudsmithPackages}/{_communityTargetsepo}/?page=1&query={_targetName} latest";
147161
repoName = _communityTargetsepo;
148162

149-
response = await _bintrayClient.GetAsync(requestUri);
163+
response = await _cloudsmithClient.GetAsync(requestUri);
150164

151-
if (response.StatusCode == HttpStatusCode.NotFound)
165+
if (responseBody == "[]")
152166
{
153167
if (Verbosity >= VerbosityLevel.Normal)
154168
{
@@ -165,24 +179,26 @@ protected async System.Threading.Tasks.Task<ExitCodes> DownloadAndExtractAsync()
165179
Console.WriteLine($"OK");
166180
}
167181

168-
// read and parse response
169-
string responseBody = await response.Content.ReadAsStringAsync();
170-
BintrayPackageInfo packageInfo = JsonConvert.DeserializeObject<BintrayPackageInfo>(responseBody);
182+
// parse response
183+
List<CloudsmithPackageInfo> packageInfo = JsonConvert.DeserializeObject<List<CloudsmithPackageInfo>>(responseBody);
171184

172185
// if no specific version was requested, use latest available
173186
if (string.IsNullOrEmpty(_fwVersion))
174187
{
175-
_fwVersion = packageInfo.LatestVersion;
188+
_fwVersion = packageInfo.ElementAt(0).Version;
176189
}
177190

191+
// grab download URL
192+
downloadUrl = packageInfo.ElementAt(0).DownloadUrl;
193+
178194
// set exposed property
179195
Version = _fwVersion;
180196

181197
stepSuccesful = true;
182198
}
183199
catch
184200
{
185-
// exception with download, assuming it's something with network connection or Bintray API
201+
// exception with download, assuming it's something with network connection or Cloudsmith API
186202
}
187203
}
188204

@@ -220,9 +236,7 @@ protected async System.Threading.Tasks.Task<ExitCodes> DownloadAndExtractAsync()
220236
try
221237
{
222238
// setup and perform download request
223-
requestUri = $"https://dl.bintray.com/nfbot/{repoName}/{fwFileName}";
224-
225-
using (var fwFileResponse = await _bintrayClient.GetAsync(requestUri))
239+
using (var fwFileResponse = await _cloudsmithClient.GetAsync(downloadUrl))
226240
{
227241
if (fwFileResponse.IsSuccessStatusCode)
228242
{
@@ -251,7 +265,7 @@ protected async System.Threading.Tasks.Task<ExitCodes> DownloadAndExtractAsync()
251265
}
252266
catch
253267
{
254-
// exception with download, assuming it's something with network connection or Bintray API
268+
// exception with download, assuming it's something with network connection or Cloudsmith API
255269
}
256270
}
257271
else

nanoFirmwareFlasher/Options.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public class Options
120120
"target",
121121
Required = false,
122122
Default = null,
123-
HelpText = "Target name. This is the target name used in the GitHub and Bintray repositories.")]
123+
HelpText = "Target name. This is the target name used in the GitHub and Cloudsmith repositories.")]
124124
public string TargetName { get; set; }
125125

126126
[Option(

0 commit comments

Comments
 (0)