mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
WIP fixing tests
This commit is contained in:
@@ -58,8 +58,8 @@ public class GitHubRepository
|
||||
.Take(1)
|
||||
.Select(x => new {
|
||||
Obj = x,
|
||||
LocalPath = Path.Combine(releaseDirectoryInfo.FullName, x.Filename),
|
||||
Filename = x.Filename,
|
||||
LocalPath = Path.Combine(releaseDirectoryInfo.FullName, x.OriginalFilename),
|
||||
Filename = x.OriginalFilename,
|
||||
});
|
||||
|
||||
foreach (var entry in releasesToDownload) {
|
||||
@@ -111,7 +111,7 @@ public class GitHubRepository
|
||||
_log.Info($"Preparing to upload latest local release to GitHub");
|
||||
|
||||
var newReleaseReq = new NewRelease(semVer.ToString()) {
|
||||
Body = ver.GetReleaseNotes(releaseDirectoryInfo.FullName, ReleaseNotesFormat.Markdown),
|
||||
//Body = ver.GetReleaseNotes(releaseDirectoryInfo.FullName, ReleaseNotesFormat.Markdown),
|
||||
Draft = true,
|
||||
Prerelease = semVer.HasMetadata || semVer.IsPrerelease,
|
||||
Name = string.IsNullOrWhiteSpace(options.ReleaseName)
|
||||
@@ -141,7 +141,7 @@ public class GitHubRepository
|
||||
|
||||
// upload nupkg's
|
||||
foreach (var r in releasesToUpload) {
|
||||
var path = Path.Combine(releaseDirectoryInfo.FullName, r.Filename);
|
||||
var path = Path.Combine(releaseDirectoryInfo.FullName, r.OriginalFilename);
|
||||
await UploadFileAsAsset(client, release, path);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,8 +84,8 @@ public class S3Repository
|
||||
.OrderByDescending(x => x.Version)
|
||||
.Take(1)
|
||||
.Select(x => new {
|
||||
LocalPath = Path.Combine(releasesDir.FullName, x.Filename),
|
||||
Filename = x.Filename,
|
||||
LocalPath = Path.Combine(releasesDir.FullName, x.OriginalFilename),
|
||||
Filename = x.OriginalFilename,
|
||||
});
|
||||
|
||||
foreach (var releaseToDownload in releasesToDownload) {
|
||||
@@ -131,7 +131,7 @@ public class S3Repository
|
||||
// apply retention policy. count '-full' versions only, then also remove corresponding delta packages
|
||||
var releaseEntries = localReleases
|
||||
.Concat(remoteReleases)
|
||||
.DistinctBy(r => r.Filename) // will preserve the local entries because they appear first
|
||||
.DistinctBy(r => r.OriginalFilename) // will preserve the local entries because they appear first
|
||||
.OrderBy(k => k.Version)
|
||||
.ThenBy(k => !k.IsDelta)
|
||||
.ToArray();
|
||||
@@ -141,7 +141,7 @@ public class S3Repository
|
||||
return;
|
||||
}
|
||||
|
||||
if (!releaseEntries.All(f => f.PackageName == releaseEntries.First().PackageName)) {
|
||||
if (!releaseEntries.All(f => f.PackageId == releaseEntries.First().PackageId)) {
|
||||
throw new Exception("There are mix-matched package Id's in local/remote RELEASES file. " +
|
||||
"Please fix the release files manually so there is only one consistent package Id present.");
|
||||
}
|
||||
@@ -219,7 +219,7 @@ public class S3Repository
|
||||
|
||||
// upload nupkg's first
|
||||
foreach (var f in nupkgFiles) {
|
||||
if (!releaseEntries.Any(r => r.Filename.Equals(f.Name, StringComparison.InvariantCultureIgnoreCase))) {
|
||||
if (!releaseEntries.Any(r => r.OriginalFilename.Equals(f.Name, StringComparison.InvariantCultureIgnoreCase))) {
|
||||
Log.Warn($"Upload file '{f.Name}' skipped (not in RELEASES file)");
|
||||
continue;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ public class S3Repository
|
||||
where key.StartsWith(_prefix, StringComparison.InvariantCultureIgnoreCase)
|
||||
let fileName = key.Substring(_prefix.Length)
|
||||
where !fileName.Contains('/') // filters out objects in folders if _prefix is empty
|
||||
where !releaseEntries.Any(r => r.Filename.Equals(fileName, StringComparison.InvariantCultureIgnoreCase))
|
||||
where !releaseEntries.Any(r => r.OriginalFilename.Equals(fileName, StringComparison.InvariantCultureIgnoreCase))
|
||||
orderby o.LastModified ascending
|
||||
select new { key, fileName, versionId = o.VersionId };
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ public class SimpleWebRepository
|
||||
.OrderByDescending(x => x.Version)
|
||||
.Take(1)
|
||||
.Select(x => new {
|
||||
LocalPath = Path.Combine(releasesDir.FullName, x.Filename),
|
||||
RemoteUrl = new Uri(Utility.EnsureTrailingSlash(uri), x.BaseUrl + x.Filename + x.Query)
|
||||
LocalPath = Path.Combine(releasesDir.FullName, x.OriginalFilename),
|
||||
RemoteUrl = new Uri(Utility.EnsureTrailingSlash(uri), x.BaseUrl + x.OriginalFilename + x.Query)
|
||||
});
|
||||
|
||||
foreach (var releaseToDownload in releasesToDownload) {
|
||||
|
||||
@@ -65,7 +65,7 @@ public class OsxReleasifyCommandRunner
|
||||
File.WriteAllText(nuspecPath, nuspecText);
|
||||
File.Copy(helper.UpdateMacPath, Path.Combine(contentsDir, "UpdateMac"), true);
|
||||
|
||||
var zipPath = Path.Combine(releaseDir.FullName, $"{packId}-{options.TargetRuntime.StringWithNoVersion}.zip");
|
||||
var zipPath = Path.Combine(releaseDir.FullName, $"{packId}-{options.TargetRuntime.ToDisplay(RidDisplayType.NoVersion)}.zip");
|
||||
if (File.Exists(zipPath)) File.Delete(zipPath);
|
||||
|
||||
// code signing all mach-o binaries
|
||||
|
||||
@@ -8,14 +8,7 @@ using Squirrel.NuGet;
|
||||
|
||||
namespace Squirrel.Packaging;
|
||||
|
||||
public interface IReleasePackage
|
||||
{
|
||||
string InputPackageFile { get; }
|
||||
string ReleasePackageFile { get; }
|
||||
SemanticVersion Version { get; }
|
||||
}
|
||||
|
||||
public class ReleasePackageBuilder : IReleasePackage
|
||||
public class ReleasePackageBuilder
|
||||
{
|
||||
private Lazy<ZipPackage> _package;
|
||||
private readonly ILogger _logger;
|
||||
@@ -35,9 +28,7 @@ public class ReleasePackageBuilder : IReleasePackage
|
||||
|
||||
public string ReleasePackageFile { get; protected set; }
|
||||
|
||||
public string Id => ReleaseEntry.ParseEntryFileName(InputPackageFile).PackageName;
|
||||
|
||||
public SemanticVersion Version => ReleaseEntry.ParseEntryFileName(InputPackageFile).Version;
|
||||
public SemanticVersion Version => _package.Value.Version;
|
||||
|
||||
public string CreateReleasePackage(string outputFile, Func<string, string> releaseNotesProcessor = null, Action<string, ZipPackage> contentsPostProcessHook = null)
|
||||
{
|
||||
@@ -111,30 +102,30 @@ public class ReleasePackageBuilder : IReleasePackage
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetSuggestedFileName(string id, string version, string runtime, bool delta = false)
|
||||
{
|
||||
var tail = delta ? "delta" : "full";
|
||||
if (String.IsNullOrEmpty(runtime)) {
|
||||
return String.Format("{0}-{1}-{2}.nupkg", id, version, tail);
|
||||
} else {
|
||||
return String.Format("{0}-{1}-{2}-{3}.nupkg", id, version, runtime, tail);
|
||||
}
|
||||
}
|
||||
//public static string GetSuggestedFileName(string id, string version, string runtime, bool delta = false)
|
||||
//{
|
||||
// var tail = delta ? "delta" : "full";
|
||||
// if (String.IsNullOrEmpty(runtime)) {
|
||||
// return String.Format("{0}-{1}-{2}.nupkg", id, version, tail);
|
||||
// } else {
|
||||
// return String.Format("{0}-{1}-{2}-{3}.nupkg", id, version, runtime, tail);
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Given a list of releases and a specified release package, returns the release package
|
||||
/// directly previous to the specified version.
|
||||
/// </summary>
|
||||
public static ReleasePackageBuilder GetPreviousRelease(ILogger logger, IEnumerable<ReleaseEntry> releaseEntries, IReleasePackage package, string targetDir, RID compatibleRid)
|
||||
{
|
||||
if (releaseEntries == null || !releaseEntries.Any()) return null;
|
||||
return Utility.FindCompatibleVersions(releaseEntries, compatibleRid)
|
||||
.Where(x => x.IsDelta == false)
|
||||
.Where(x => x.Version < package.Version)
|
||||
.OrderByDescending(x => x.Version)
|
||||
.Select(x => new ReleasePackageBuilder(logger, Path.Combine(targetDir, x.Filename), true))
|
||||
.FirstOrDefault();
|
||||
}
|
||||
//public static ReleasePackageBuilder GetPreviousRelease(ILogger logger, IEnumerable<ReleaseEntry> releaseEntries, ReleasePackageBuilder package, string targetDir, RID compatibleRid)
|
||||
//{
|
||||
// if (releaseEntries == null || !releaseEntries.Any()) return null;
|
||||
// return Utility.FindCompatibleVersions(releaseEntries, compatibleRid)
|
||||
// .Where(x => x.IsDelta == false)
|
||||
// .Where(x => x.Version < package.Version)
|
||||
// .OrderByDescending(x => x.Version)
|
||||
// .Select(x => new ReleasePackageBuilder(logger, Path.Combine(targetDir, x.Filename), true))
|
||||
// .FirstOrDefault();
|
||||
//}
|
||||
|
||||
static Task extractZipWithEscaping(string zipFilePath, string outFolder)
|
||||
{
|
||||
|
||||
@@ -7,6 +7,9 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
// https://dev.to/emrahsungu/how-to-compare-two-files-using-net-really-really-fast-2pd9
|
||||
// https://github.com/SnowflakePowered/vcdiff
|
||||
|
||||
namespace Squirrel.Compression
|
||||
{
|
||||
public class DeltaPackage
|
||||
|
||||
@@ -80,14 +80,25 @@ namespace Squirrel.NuGet
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetMetadata(string nuspecPath, IEnumerable<string> runtimes, RID rid)
|
||||
public static void SetMetadata(string nuspecPath, string mainExe, IEnumerable<string> runtimes, RID rid)
|
||||
{
|
||||
Dictionary<string, string> toSet = new();
|
||||
|
||||
if (runtimes.Any())
|
||||
if (runtimes.Any()) {
|
||||
toSet.Add("runtimeDependencies", String.Join(",", runtimes));
|
||||
if (rid?.IsValid == true)
|
||||
toSet.Add("rid", rid.StringWithFullVersion);
|
||||
}
|
||||
|
||||
if (rid?.IsValid == true) {
|
||||
toSet.Add("rid", rid.ToDisplay(RidDisplayType.FullVersion));
|
||||
toSet.Add("os", rid.BaseRID.GetOsShortName());
|
||||
if (rid.HasVersion)
|
||||
toSet.Add("osMinVersion", rid.Version.ToString());
|
||||
if (rid.HasArchitecture)
|
||||
toSet.Add("machineArchitecture", rid.Architecture.ToString());
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(mainExe))
|
||||
toSet.Add("mainExe", mainExe);
|
||||
|
||||
if (!toSet.Any())
|
||||
return;
|
||||
|
||||
@@ -136,14 +136,15 @@ namespace Squirrel
|
||||
public static bool operator >=(RuntimeVersion v1, RuntimeVersion v2) => v2 <= v1;
|
||||
}
|
||||
|
||||
public enum RidDisplayType
|
||||
{
|
||||
NoVersion,
|
||||
ShortVersion,
|
||||
FullVersion,
|
||||
}
|
||||
|
||||
public class RID
|
||||
{
|
||||
public string StringWithFullVersion => ToString(true, false);
|
||||
|
||||
public string StringWithShortVersion => ToString(true, true);
|
||||
|
||||
public string StringWithNoVersion => ToString(false, false);
|
||||
|
||||
internal const char VersionDelimiter = '.';
|
||||
internal const char ArchitectureDelimiter = '-';
|
||||
internal const char QualifierDelimiter = '-';
|
||||
@@ -154,22 +155,22 @@ namespace Squirrel
|
||||
public RuntimeCpu Architecture { get; set; }
|
||||
public string Qualifier { get; set; }
|
||||
|
||||
public override string ToString() => ToString(true, false);
|
||||
public override string ToString() => ToDisplay(RidDisplayType.FullVersion);
|
||||
|
||||
private string ToString(bool withVersion, bool shortVersion)
|
||||
public string ToDisplay(RidDisplayType type)
|
||||
{
|
||||
if (!IsValid) return "";
|
||||
StringBuilder builder = new StringBuilder(BaseRID.GetOsShortName());
|
||||
|
||||
if (withVersion && HasVersion) {
|
||||
if (HasVersion) {
|
||||
//if (!OmitVersionDelimiter) {
|
||||
// builder.Append(VersionDelimiter);
|
||||
//}
|
||||
|
||||
if (shortVersion) {
|
||||
builder.Append(Version.Major);
|
||||
} else {
|
||||
if (type == RidDisplayType.FullVersion) {
|
||||
builder.Append(Version);
|
||||
} else if (type == RidDisplayType.ShortVersion) {
|
||||
builder.Append(Version.Major);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,131 +28,99 @@ namespace Squirrel
|
||||
/// Represents a Squirrel release, as described in a RELEASES file - usually also with an
|
||||
/// accompanying package containing the files needed to apply the release.
|
||||
/// </summary>
|
||||
public interface IReleaseEntry
|
||||
[DataContract]
|
||||
public class ReleaseEntry
|
||||
{
|
||||
/// <summary> The SHA1 checksum of the update package containing this release. </summary>
|
||||
string SHA1 { get; }
|
||||
|
||||
/// <summary> The filename of the update package containing this release. </summary>
|
||||
string Filename { get; }
|
||||
|
||||
/// <summary> The size in bytes of the update package containing this release. </summary>
|
||||
long Filesize { get; }
|
||||
|
||||
/// <summary> Whether this package represents a full update, or a delta update. </summary>
|
||||
bool IsDelta { get; }
|
||||
|
||||
/// <summary> The unparsed text used to construct this release. </summary>
|
||||
string EntryAsString { get; }
|
||||
|
||||
/// <summary> The version of this release. </summary>
|
||||
SemanticVersion Version { get; }
|
||||
/// <summary> The release identity - including id, version and so forth. </summary>*
|
||||
[IgnoreDataMember] public ReleaseEntryName Identity { get; protected set; }
|
||||
|
||||
/// <summary> The name or Id of the package containing this release. </summary>
|
||||
string PackageName { get; }
|
||||
[DataMember] public string PackageId => Identity.PackageId;
|
||||
|
||||
/// <summary>
|
||||
/// The percentage of users this package has been released to. This release
|
||||
/// may or may not be applied if the current user is not in the staging group.
|
||||
/// </summary>
|
||||
float? StagingPercentage { get; }
|
||||
/// <summary> The version of this release. </summary>
|
||||
[DataMember] public SemanticVersion Version => Identity.Version;
|
||||
|
||||
/// <summary> Whether this package represents a full update, or a delta update. </summary>
|
||||
[DataMember] public bool IsDelta => Identity.IsDelta;
|
||||
|
||||
/// <summary>
|
||||
/// The runtime identifier parsed from the file name.
|
||||
/// Used to determine if this package is suitable for the current operating system.
|
||||
/// </summary>
|
||||
RID Rid { get; }
|
||||
[DataMember] public RID Rid => Identity.Rid;
|
||||
|
||||
/// <summary>
|
||||
/// Given a local directory containing a package corresponding to this release, returns the
|
||||
/// correspoding release notes from within the package.
|
||||
/// </summary>
|
||||
string GetReleaseNotes(string packageDirectory, ReleaseNotesFormat format);
|
||||
|
||||
/// <summary>
|
||||
/// Given a local directory containing a package corresponding to this release,
|
||||
/// returns the iconUrl specified in the package.
|
||||
/// </summary>
|
||||
Uri GetIconUrl(string packageDirectory);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IReleaseEntry" />
|
||||
[DataContract]
|
||||
public class ReleaseEntry : IReleaseEntry
|
||||
{
|
||||
/// <inheritdoc />
|
||||
/// <summary> The SHA1 checksum of the update package containing this release. </summary>
|
||||
[DataMember] public string SHA1 { get; protected set; }
|
||||
/// <inheritdoc />
|
||||
|
||||
/// <summary> If the release corresponds to a remote http location, this will be the base url. </summary>
|
||||
[DataMember] public string BaseUrl { get; protected set; }
|
||||
/// <inheritdoc />
|
||||
[DataMember] public string Filename { get; protected set; }
|
||||
/// <inheritdoc />
|
||||
|
||||
/// <summary> The http url query (if applicable). </summary>
|
||||
[DataMember] public string Query { get; protected set; }
|
||||
/// <inheritdoc />
|
||||
|
||||
/// <summary> The size in bytes of the update package containing this release. </summary>
|
||||
[DataMember] public long Filesize { get; protected set; }
|
||||
/// <inheritdoc />
|
||||
[DataMember] public bool IsDelta { get; protected set; }
|
||||
/// <inheritdoc />
|
||||
|
||||
/// <summary>
|
||||
/// The percentage of users this package has been released to. This release
|
||||
/// may or may not be applied if the current user is not in the staging group.
|
||||
/// </summary>
|
||||
[DataMember] public float? StagingPercentage { get; protected set; }
|
||||
/// <inheritdoc />
|
||||
[DataMember] public RID Rid { get; protected set; }
|
||||
|
||||
/// <summary> The filename of the update package containing this release. </summary>
|
||||
[DataMember] public string OriginalFilename { get; protected set; }
|
||||
|
||||
/// <summary> The unparsed text used to construct this release. </summary>
|
||||
[IgnoreDataMember]
|
||||
public string EntryAsString {
|
||||
get {
|
||||
if (StagingPercentage != null) {
|
||||
return String.Format("{0} {1}{2} {3} # {4}", SHA1, BaseUrl, OriginalFilename, Filesize, stagingPercentageAsString(StagingPercentage.Value));
|
||||
} else {
|
||||
return String.Format("{0} {1}{2} {3}", SHA1, BaseUrl, OriginalFilename, Filesize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a new instance of <see cref="ReleaseEntry"/>.
|
||||
/// </summary>
|
||||
protected ReleaseEntry(string sha1, string filename, long filesize, string baseUrl = null, string query = null, float? stagingPercentage = null)
|
||||
protected internal ReleaseEntry(string sha1, string filename, long filesize, string baseUrl = null, string query = null, float? stagingPercentage = null)
|
||||
{
|
||||
Contract.Requires(sha1 != null && sha1.Length == 40);
|
||||
Contract.Requires(filename != null);
|
||||
Contract.Requires(filename.Contains(Path.DirectorySeparatorChar) == false);
|
||||
Contract.Requires(filesize > 0);
|
||||
|
||||
SHA1 = sha1; BaseUrl = baseUrl; Filename = filename; Query = query; Filesize = filesize; StagingPercentage = stagingPercentage;
|
||||
|
||||
var identity = ParseEntryFileName(Filename);
|
||||
Version = identity.Version;
|
||||
PackageName = identity.PackageName;
|
||||
IsDelta = identity.IsDelta;
|
||||
Rid = identity.Rid;
|
||||
SHA1 = sha1;
|
||||
BaseUrl = baseUrl;
|
||||
Query = query;
|
||||
Filesize = filesize;
|
||||
StagingPercentage = stagingPercentage;
|
||||
OriginalFilename = filename;
|
||||
Identity = ReleaseEntryName.FromEntryFileName(filename);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[IgnoreDataMember]
|
||||
public string EntryAsString {
|
||||
get {
|
||||
if (StagingPercentage != null) {
|
||||
return String.Format("{0} {1}{2} {3} # {4}", SHA1, BaseUrl, Filename, Filesize, stagingPercentageAsString(StagingPercentage.Value));
|
||||
} else {
|
||||
return String.Format("{0} {1}{2} {3}", SHA1, BaseUrl, Filename, Filesize);
|
||||
}
|
||||
}
|
||||
}
|
||||
///// <summary>
|
||||
///// Given a local directory containing a package corresponding to this release, returns the
|
||||
///// correspoding release notes from within the package.
|
||||
///// </summary>
|
||||
//public string GetReleaseNotes(string packageDirectory, ReleaseNotesFormat format)
|
||||
//{
|
||||
// var zp = new ZipPackage(Path.Combine(packageDirectory, Filename));
|
||||
// return format switch {
|
||||
// ReleaseNotesFormat.Markdown => zp.ReleaseNotes,
|
||||
// ReleaseNotesFormat.Html => zp.ReleaseNotesHtml,
|
||||
// _ => null,
|
||||
// };
|
||||
//}
|
||||
|
||||
/// <inheritdoc />
|
||||
[IgnoreDataMember]
|
||||
public SemanticVersion Version { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
[IgnoreDataMember]
|
||||
public string PackageName { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string GetReleaseNotes(string packageDirectory, ReleaseNotesFormat format)
|
||||
{
|
||||
var zp = new ZipPackage(Path.Combine(packageDirectory, Filename));
|
||||
return format switch {
|
||||
ReleaseNotesFormat.Markdown => zp.ReleaseNotes,
|
||||
ReleaseNotesFormat.Html => zp.ReleaseNotesHtml,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Uri GetIconUrl(string packageDirectory)
|
||||
{
|
||||
var zp = new ZipPackage(Path.Combine(packageDirectory, Filename));
|
||||
return zp.IconUrl;
|
||||
}
|
||||
///// <inheritdoc />
|
||||
//public Uri GetIconUrl(string packageDirectory)
|
||||
//{
|
||||
// var zp = new ZipPackage(Path.Combine(packageDirectory, Filename));
|
||||
// return zp.IconUrl;
|
||||
//}
|
||||
|
||||
static readonly Regex entryRegex = new Regex(@"^([0-9a-fA-F]{40})\s+(\S+)\s+(\d+)[\r]*$");
|
||||
static readonly Regex commentRegex = new Regex(@"\s*#.*$");
|
||||
@@ -370,73 +338,9 @@ namespace Squirrel
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string ToString()
|
||||
{
|
||||
return Filename;
|
||||
}
|
||||
public override string ToString() => Identity.ToFileName();
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Filename.GetHashCode();
|
||||
}
|
||||
|
||||
static readonly Regex _suffixRegex = new Regex(@"(-full|-delta)?\.nupkg$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
static readonly Regex _versionStartRegex = new Regex(@"[\.-](0|[1-9]\d*)\.(0|[1-9]\d*)($|[^\d])", RegexOptions.Compiled);
|
||||
static readonly Regex _ridRegex = new Regex(@"-(?<os>osx|win)\.?(?<ver>[\d\.]+)?(?:-(?<arch>(?:x|arm)\d{2}))?$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
internal class EntryNameInfo
|
||||
{
|
||||
public string PackageName { get; set; }
|
||||
public SemanticVersion Version { get; set; }
|
||||
public bool IsDelta { get; set; }
|
||||
public RID Rid { get; set; }
|
||||
|
||||
public EntryNameInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public EntryNameInfo(string packageName, SemanticVersion version, bool isDelta, RID rid)
|
||||
{
|
||||
PackageName = packageName;
|
||||
Version = version;
|
||||
IsDelta = isDelta;
|
||||
Rid = rid;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Takes a filename such as 'My-Cool3-App-1.0.1-build.23-full.nupkg' and separates it into
|
||||
/// it's name and version (eg. 'My-Cool3-App', and '1.0.1-build.23'). Returns null values if
|
||||
/// the filename can not be parsed.
|
||||
/// </summary>
|
||||
internal static EntryNameInfo ParseEntryFileName(string fileName)
|
||||
{
|
||||
if (!fileName.EndsWith(".nupkg", StringComparison.OrdinalIgnoreCase))
|
||||
return new EntryNameInfo(null, null, false, null);
|
||||
|
||||
bool delta = Path.GetFileNameWithoutExtension(fileName).EndsWith("-delta", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
var nameAndVer = _suffixRegex.Replace(Path.GetFileName(fileName), "");
|
||||
|
||||
var match = _versionStartRegex.Match(nameAndVer);
|
||||
if (!match.Success)
|
||||
return new EntryNameInfo(null, null, delta, null);
|
||||
|
||||
var verIdx = match.Index;
|
||||
var name = nameAndVer.Substring(0, verIdx);
|
||||
var version = nameAndVer.Substring(verIdx + 1);
|
||||
|
||||
RID rid = null;
|
||||
var ridMatch = _ridRegex.Match(version);
|
||||
|
||||
if (ridMatch.Success) {
|
||||
rid = RID.Parse(ridMatch.Value.TrimStart('-'));
|
||||
version = version.Substring(0, ridMatch.Index);
|
||||
}
|
||||
|
||||
var semVer = NuGetVersion.Parse(version);
|
||||
return new EntryNameInfo(name, semVer, delta, rid);
|
||||
}
|
||||
public override int GetHashCode() => Identity.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
82
src/Squirrel/ReleaseEntryName.cs
Normal file
82
src/Squirrel/ReleaseEntryName.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.CodeDom;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using NuGet.Versioning;
|
||||
|
||||
namespace Squirrel
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the information that can be parsed from a release entry filename.
|
||||
/// </summary>
|
||||
public sealed record ReleaseEntryName
|
||||
{
|
||||
/// <summary> The package Id. </summary>
|
||||
public string PackageId { get; private set; }
|
||||
|
||||
/// <summary> The package version. </summary>
|
||||
public SemanticVersion Version { get; private set; }
|
||||
|
||||
/// <summary> Whether this is a delta (patch) package, or a full update package. </summary>
|
||||
public bool IsDelta { get; private set; }
|
||||
|
||||
/// <summary> The target machine runtime identifier (eg. win-x64). </summary>
|
||||
public RID Rid { get; private set; }
|
||||
|
||||
private static readonly Regex _suffixRegex = new Regex(@"(-full|-delta)?\.nupkg$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex _versionStartRegex = new Regex(@"[\.-](0|[1-9]\d*)\.(0|[1-9]\d*)($|[^\d])", RegexOptions.Compiled);
|
||||
private static readonly Regex _ridRegex = new Regex(@"-(?:(?<os>osx|win)(?<ver>[\d\.]+)?)?-?(?<arch>x64|x86|arm64)?$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
/// <summary>
|
||||
/// Create a new ReleaseEntryName from the given package name, version, delta status, and runtime identifier.
|
||||
/// </summary>
|
||||
public ReleaseEntryName(string packageName, SemanticVersion version, bool isDelta, RID rid)
|
||||
{
|
||||
PackageId = packageName;
|
||||
Version = version;
|
||||
IsDelta = isDelta;
|
||||
Rid = rid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Takes a filename such as 'My-Cool3-App-1.0.1-build.23-full.nupkg' and separates it into
|
||||
/// it's name and version (eg. 'My-Cool3-App', and '1.0.1-build.23'). Returns null values if
|
||||
/// the filename can not be parsed.
|
||||
/// </summary>
|
||||
public static ReleaseEntryName FromEntryFileName(string fileName)
|
||||
{
|
||||
if (!fileName.EndsWith(".nupkg", StringComparison.OrdinalIgnoreCase))
|
||||
return new ReleaseEntryName(null, null, false, null);
|
||||
|
||||
bool delta = Path.GetFileNameWithoutExtension(fileName).EndsWith("-delta", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
var nameAndVer = _suffixRegex.Replace(Path.GetFileName(fileName), "");
|
||||
|
||||
var match = _versionStartRegex.Match(nameAndVer);
|
||||
if (!match.Success)
|
||||
return new ReleaseEntryName(null, null, delta, null);
|
||||
|
||||
var verIdx = match.Index;
|
||||
var name = nameAndVer.Substring(0, verIdx);
|
||||
var version = nameAndVer.Substring(verIdx + 1);
|
||||
|
||||
RID rid = null;
|
||||
var ridMatch = _ridRegex.Match(version);
|
||||
|
||||
if (ridMatch.Success) {
|
||||
var ridStr = ridMatch.Value.TrimStart('-', '[').TrimEnd(']');
|
||||
rid = RID.Parse(ridStr);
|
||||
version = version.Substring(0, ridMatch.Index);
|
||||
}
|
||||
|
||||
var semVer = NuGetVersion.Parse(version);
|
||||
return new ReleaseEntryName(name, semVer, delta, rid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate the file name which would represent this ReleaseEntryName.
|
||||
/// </summary>
|
||||
public string ToFileName() =>
|
||||
$"{PackageId}-{Version}{(Rid != null ? $"-{Rid.ToDisplay(RidDisplayType.NoVersion)}" : "")}{(IsDelta ? "-delta" : "-full")}.nupkg";
|
||||
}
|
||||
}
|
||||
@@ -154,7 +154,7 @@ namespace Squirrel.Sources
|
||||
|
||||
// this might be a browser url or an api url (depending on whether we have a AccessToken or not)
|
||||
// https://docs.github.com/en/rest/reference/releases#get-a-release-asset
|
||||
var assetUrl = GetAssetUrlFromName(Release, releaseEntry.Filename);
|
||||
var assetUrl = GetAssetUrlFromName(Release, releaseEntry.OriginalFilename);
|
||||
return Downloader.DownloadFile(assetUrl, localFile, progress, Authorization, "application/octet-stream");
|
||||
}
|
||||
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace Squirrel.Sources
|
||||
"GitLabSource.Release before calling this function.");
|
||||
}
|
||||
|
||||
var assetUrl = GetAssetUrlFromName(Release, releaseEntry.Filename);
|
||||
var assetUrl = GetAssetUrlFromName(Release, releaseEntry.OriginalFilename);
|
||||
return Downloader.DownloadFile(assetUrl, localFile, progress, Authorization, "application/octet-stream");
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Squirrel.Sources
|
||||
/// <inheritdoc />
|
||||
public virtual Task DownloadReleaseEntry(ReleaseEntry releaseEntry, string localFile, Action<int> progress)
|
||||
{
|
||||
var releasePath = Path.Combine(BaseDirectory.FullName, releaseEntry.Filename);
|
||||
var releasePath = Path.Combine(BaseDirectory.FullName, releaseEntry.OriginalFilename);
|
||||
if (!File.Exists(releasePath))
|
||||
throw new Exception($"The file '{releasePath}' does not exist. The packages directory is invalid.");
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Squirrel.Sources
|
||||
}
|
||||
|
||||
if (latestLocalRelease != null) {
|
||||
args.Add("id", latestLocalRelease.PackageName);
|
||||
args.Add("id", latestLocalRelease.PackageId);
|
||||
args.Add("localVersion", latestLocalRelease.Version.ToString());
|
||||
}
|
||||
|
||||
@@ -71,8 +71,8 @@ namespace Squirrel.Sources
|
||||
if (localFile == null) throw new ArgumentNullException(nameof(localFile));
|
||||
|
||||
var releaseUri = releaseEntry.BaseUrl == null
|
||||
? releaseEntry.Filename
|
||||
: Utility.AppendPathToUri(new Uri(releaseEntry.BaseUrl), releaseEntry.Filename).ToString();
|
||||
? releaseEntry.OriginalFilename
|
||||
: Utility.AppendPathToUri(new Uri(releaseEntry.BaseUrl), releaseEntry.OriginalFilename).ToString();
|
||||
|
||||
if (!String.IsNullOrEmpty(releaseEntry.Query)) {
|
||||
releaseUri += releaseEntry.Query;
|
||||
@@ -82,11 +82,11 @@ namespace Squirrel.Sources
|
||||
// absolute url (eg. "https://example.com/MyPackage.nupkg"). In the former case
|
||||
var sourceBaseUri = Utility.EnsureTrailingSlash(BaseUri);
|
||||
|
||||
var source = Utility.IsHttpUrl(releaseUri)
|
||||
var source = Utility.IsHttpUrl(releaseUri)
|
||||
? new Uri(sourceBaseUri, releaseUri).ToString()
|
||||
: Utility.AppendPathToUri(sourceBaseUri, releaseUri).ToString();
|
||||
|
||||
_logger.Info($"Downloading '{releaseEntry.Filename}' from '{source}'.");
|
||||
_logger.Info($"Downloading '{releaseEntry.OriginalFilename}' from '{source}'.");
|
||||
return Downloader.DownloadFile(source, localFile, progress);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,22 +50,22 @@ namespace Squirrel
|
||||
this.PackageDirectory = packageDirectory;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all the release notes for pending packages (ie. <see cref="ReleasesToApply"/>)
|
||||
/// </summary>
|
||||
public Dictionary<ReleaseEntry, string> FetchReleaseNotes(ReleaseNotesFormat format)
|
||||
{
|
||||
return ReleasesToApply
|
||||
.SelectMany(x => {
|
||||
try {
|
||||
var releaseNotes = x.GetReleaseNotes(PackageDirectory, format);
|
||||
return EnumerableExtensions.Return(Tuple.Create(x, releaseNotes));
|
||||
} catch (Exception ex) {
|
||||
return Enumerable.Empty<Tuple<ReleaseEntry, string>>();
|
||||
}
|
||||
})
|
||||
.ToDictionary(k => k.Item1, v => v.Item2);
|
||||
}
|
||||
// /// <summary>
|
||||
// /// Retrieves all the release notes for pending packages (ie. <see cref="ReleasesToApply"/>)
|
||||
// /// </summary>
|
||||
// public Dictionary<ReleaseEntry, string> FetchReleaseNotes(ReleaseNotesFormat format)
|
||||
// {
|
||||
// return ReleasesToApply
|
||||
// .SelectMany(x => {
|
||||
// try {
|
||||
// var releaseNotes = x.GetReleaseNotes(PackageDirectory, format);
|
||||
// return EnumerableExtensions.Return(Tuple.Create(x, releaseNotes));
|
||||
// } catch (Exception ex) {
|
||||
// return Enumerable.Empty<Tuple<ReleaseEntry, string>>();
|
||||
// }
|
||||
// })
|
||||
// .ToDictionary(k => k.Item1, v => v.Item2);
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="UpdateInfo"/> from a current release and a list of future releases
|
||||
|
||||
27
test/Directory.Build.props
Normal file
27
test/Directory.Build.props
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<IsPackable>false</IsPackable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<IsTest>true</IsTest>
|
||||
<NoWarn>$(NoWarn);CS1998,xUnit2015,xUnit2017,xUnit2005,xUnit2009,xUnit2013,xUnit2004;CA2007</NoWarn>
|
||||
<SignAssembly>True</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>..\..\Squirrel.snk</AssemblyOriginatorKeyFile>
|
||||
<IsPackable>false</IsPackable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\GlobalUsings.cs" Link="GlobalUsings.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="xunit" Version="2.6.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.5" PrivateAssets="All" />
|
||||
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
|
||||
<PackageReference Include="Divergic.Logging.Xunit" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -4,6 +4,6 @@ global using System.IO;
|
||||
global using System.Linq;
|
||||
global using System.Threading.Tasks;
|
||||
global using Microsoft.Extensions.Logging;
|
||||
//global using Microsoft.Extensions.Logging.Abstractions;
|
||||
global using Microsoft.Extensions.Logging.Abstractions;
|
||||
global using Xunit;
|
||||
global using Xunit.Abstractions;
|
||||
@@ -1,4 +1,6 @@
|
||||
namespace Squirrel.CommandLine.Tests;
|
||||
using Squirrel.Csq.Commands;
|
||||
|
||||
namespace Squirrel.CommandLine.Tests;
|
||||
|
||||
public abstract class BaseCommandTests<T> : TempFileTestBase
|
||||
where T : BaseCommand, new()
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace Squirrel.CommandLine.Tests.Commands;
|
||||
using System.CommandLine;
|
||||
using Squirrel.Csq.Commands;
|
||||
|
||||
namespace Squirrel.CommandLine.Tests.Commands;
|
||||
|
||||
public abstract class GitHubCommandTests<T> : BaseCommandTests<T>
|
||||
where T : GitHubBaseCommand, new()
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
|
||||
using System.CommandLine;
|
||||
using Squirrel.Csq.Commands;
|
||||
|
||||
namespace Squirrel.CommandLine.Tests.Commands;
|
||||
|
||||
public class HttpDownloadCommandTests : BaseCommandTests<HttpDownloadCommand>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
namespace Squirrel.CommandLine.Tests.Commands;
|
||||
using System.CommandLine;
|
||||
using Squirrel.Csq.Commands;
|
||||
|
||||
namespace Squirrel.CommandLine.Tests.Commands;
|
||||
|
||||
public abstract class S3CommandTests<T> : BaseCommandTests<T>
|
||||
where T : S3BaseCommand, new()
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
|
||||
using System.CommandLine;
|
||||
using Squirrel.Csq.Commands;
|
||||
|
||||
namespace Squirrel.CommandLine.Tests.Commands;
|
||||
|
||||
public abstract class ReleaseCommandTests<T> : BaseCommandTests<T>
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
global using System;
|
||||
global using System.CommandLine;
|
||||
global using System.Collections.Generic;
|
||||
global using System.IO;
|
||||
global using System.Linq;
|
||||
global using System.Threading.Tasks;
|
||||
global using Microsoft.Extensions.Logging;
|
||||
global using Xunit;
|
||||
global using Xunit.Abstractions;
|
||||
global using Squirrel.Csq.Commands;
|
||||
@@ -1,19 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsTest>true</IsTest>
|
||||
<IsPackable>false</IsPackable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="xunit" Version="2.6.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.5" PrivateAssets="All" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Squirrel.Csq\Squirrel.Csq.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Xunit.Sdk;
|
||||
using System.Threading;
|
||||
using Xunit.Sdk;
|
||||
|
||||
namespace Squirrel.CommandLine.Tests;
|
||||
|
||||
|
||||
@@ -1,26 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<IsTest>true</IsTest>
|
||||
<NoWarn>$(NoWarn);CS1998,xUnit2015,xUnit2017,xUnit2005,xUnit2009,xUnit2013,xUnit2004;CA2007</NoWarn>
|
||||
<SignAssembly>True</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>..\..\Squirrel.snk</AssemblyOriginatorKeyFile>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="xunit" Version="2.6.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.5" PrivateAssets="All" />
|
||||
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
|
||||
<PackageReference Include="Divergic.Logging.Xunit" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Squirrel.Packaging.Windows\Squirrel.Packaging.Windows.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -3,28 +3,17 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics.Contracts;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using NuGet;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace Squirrel.Tests.Legacy
|
||||
namespace Squirrel.Tests.OldSquirrel
|
||||
{
|
||||
public interface IReleaseEntry
|
||||
{
|
||||
string SHA1 { get; }
|
||||
string Filename { get; }
|
||||
long Filesize { get; }
|
||||
bool IsDelta { get; }
|
||||
string EntryAsString { get; }
|
||||
SemanticVersion Version { get; }
|
||||
string PackageName { get; }
|
||||
float? StagingPercentage { get; }
|
||||
//string GetReleaseNotes(string packageDirectory);
|
||||
//Uri GetIconUrl(string packageDirectory);
|
||||
}
|
||||
|
||||
[DataContract]
|
||||
public class ReleaseEntry : IReleaseEntry
|
||||
public class ReleaseEntry
|
||||
{
|
||||
[DataMember] public string SHA1 { get; protected set; }
|
||||
[DataMember] public string BaseUrl { get; protected set; }
|
||||
@@ -55,18 +44,8 @@ namespace Squirrel.Tests.Legacy
|
||||
}
|
||||
}
|
||||
|
||||
static readonly Regex _suffixRegex = new Regex(@"(-full|-delta)?\.nupkg$", RegexOptions.Compiled);
|
||||
static readonly Regex _versionRegex = new Regex(@"\d+(\.\d+){0,3}(-[A-Za-z][0-9A-Za-z-]*)?$", RegexOptions.Compiled);
|
||||
|
||||
public static SemanticVersion ToSemanticVersion(string fileName)
|
||||
{
|
||||
var name = _suffixRegex.Replace(fileName, "");
|
||||
var version = _versionRegex.Match(name).Value;
|
||||
return new SemanticVersion(version);
|
||||
}
|
||||
|
||||
[IgnoreDataMember]
|
||||
public SemanticVersion Version { get { return ToSemanticVersion(Filename); } }
|
||||
public SemanticVersion Version { get { return Filename.ToSemanticVersion(); } }
|
||||
|
||||
static readonly Regex packageNameRegex = new Regex(@"^([\w-]+)-\d+\..+\.nupkg$");
|
||||
[IgnoreDataMember]
|
||||
@@ -179,7 +158,7 @@ namespace Squirrel.Tests.Legacy
|
||||
return new ReleaseEntry[0];
|
||||
}
|
||||
|
||||
fileContents = Utility.RemoveByteOrderMarkerIfPresent(fileContents);
|
||||
//fileContents = Utility.RemoveByteOrderMarkerIfPresent(fileContents);
|
||||
|
||||
var ret = fileContents.Split('\n')
|
||||
.Where(x => !String.IsNullOrWhiteSpace(x))
|
||||
@@ -196,7 +175,7 @@ namespace Squirrel.Tests.Legacy
|
||||
return new ReleaseEntry[0];
|
||||
}
|
||||
|
||||
fileContents = Utility.RemoveByteOrderMarkerIfPresent(fileContents);
|
||||
//fileContents = Utility.RemoveByteOrderMarkerIfPresent(fileContents);
|
||||
|
||||
var ret = fileContents.Split('\n')
|
||||
.Where(x => !String.IsNullOrWhiteSpace(x))
|
||||
@@ -208,44 +187,44 @@ namespace Squirrel.Tests.Legacy
|
||||
}
|
||||
|
||||
|
||||
public static void WriteReleaseFile(IEnumerable<ReleaseEntry> releaseEntries, Stream stream)
|
||||
{
|
||||
Contract.Requires(releaseEntries != null && releaseEntries.Any());
|
||||
Contract.Requires(stream != null);
|
||||
//public static void WriteReleaseFile(IEnumerable<ReleaseEntry> releaseEntries, Stream stream)
|
||||
//{
|
||||
// Contract.Requires(releaseEntries != null && releaseEntries.Any());
|
||||
// Contract.Requires(stream != null);
|
||||
|
||||
using (var sw = new StreamWriter(stream, Encoding.UTF8)) {
|
||||
sw.Write(String.Join("\n", releaseEntries
|
||||
.OrderBy(x => x.Version)
|
||||
.ThenByDescending(x => x.IsDelta)
|
||||
.Select(x => x.EntryAsString)));
|
||||
}
|
||||
}
|
||||
// using (var sw = new StreamWriter(stream, Encoding.UTF8)) {
|
||||
// sw.Write(String.Join("\n", releaseEntries
|
||||
// .OrderBy(x => x.Version)
|
||||
// .ThenByDescending(x => x.IsDelta)
|
||||
// .Select(x => x.EntryAsString)));
|
||||
// }
|
||||
//}
|
||||
|
||||
public static void WriteReleaseFile(IEnumerable<ReleaseEntry> releaseEntries, string path)
|
||||
{
|
||||
Contract.Requires(releaseEntries != null && releaseEntries.Any());
|
||||
Contract.Requires(!String.IsNullOrEmpty(path));
|
||||
//public static void WriteReleaseFile(IEnumerable<ReleaseEntry> releaseEntries, string path)
|
||||
//{
|
||||
// Contract.Requires(releaseEntries != null && releaseEntries.Any());
|
||||
// Contract.Requires(!String.IsNullOrEmpty(path));
|
||||
|
||||
using (var f = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None)) {
|
||||
WriteReleaseFile(releaseEntries, f);
|
||||
}
|
||||
}
|
||||
// using (var f = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None)) {
|
||||
// WriteReleaseFile(releaseEntries, f);
|
||||
// }
|
||||
//}
|
||||
|
||||
public static ReleaseEntry GenerateFromFile(Stream file, string filename, string baseUrl = null)
|
||||
{
|
||||
Contract.Requires(file != null && file.CanRead);
|
||||
Contract.Requires(!String.IsNullOrEmpty(filename));
|
||||
//public static ReleaseEntry GenerateFromFile(Stream file, string filename, string baseUrl = null)
|
||||
//{
|
||||
// Contract.Requires(file != null && file.CanRead);
|
||||
// Contract.Requires(!String.IsNullOrEmpty(filename));
|
||||
|
||||
var hash = Utility.CalculateStreamSHA1(file);
|
||||
return new ReleaseEntry(hash, filename, file.Length, filenameIsDeltaFile(filename), baseUrl);
|
||||
}
|
||||
// var hash = Utility.CalculateStreamSHA1(file);
|
||||
// return new ReleaseEntry(hash, filename, file.Length, filenameIsDeltaFile(filename), baseUrl);
|
||||
//}
|
||||
|
||||
public static ReleaseEntry GenerateFromFile(string path, string baseUrl = null)
|
||||
{
|
||||
using (var inf = File.OpenRead(path)) {
|
||||
return GenerateFromFile(inf, Path.GetFileName(path), baseUrl);
|
||||
}
|
||||
}
|
||||
//public static ReleaseEntry GenerateFromFile(string path, string baseUrl = null)
|
||||
//{
|
||||
// using (var inf = File.OpenRead(path)) {
|
||||
// return GenerateFromFile(inf, Path.GetFileName(path), baseUrl);
|
||||
// }
|
||||
//}
|
||||
|
||||
//public static List<ReleaseEntry> BuildReleasesFile(string releasePackagesDir)
|
||||
//{
|
||||
@@ -300,7 +279,7 @@ namespace Squirrel.Tests.Legacy
|
||||
// return releaseEntries
|
||||
// .Where(x => x.IsDelta == false)
|
||||
// .Where(x => x.Version < package.ToSemanticVersion())
|
||||
// .OrderByDescending(x => x.Version)
|
||||
// .OrderByDescending(x => x.Version)
|
||||
// .Select(x => new ReleasePackage(Path.Combine(targetDir, x.Filename), true))
|
||||
// .FirstOrDefault();
|
||||
//}
|
||||
27
test/Squirrel.Tests/OldSquirrel/ReleaseExtensions.cs
Normal file
27
test/Squirrel.Tests/OldSquirrel/ReleaseExtensions.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Squirrel.Tests.OldSquirrel
|
||||
{
|
||||
public static class VersionExtensions
|
||||
{
|
||||
static readonly Regex _suffixRegex = new Regex(@"(-full|-delta)?\.nupkg$", RegexOptions.Compiled);
|
||||
static readonly Regex _versionRegex = new Regex(@"\d+(\.\d+){0,3}(-[A-Za-z][0-9A-Za-z-]*)?$", RegexOptions.Compiled);
|
||||
|
||||
//public static SemanticVersion ToSemanticVersion(this IReleasePackage package)
|
||||
//{
|
||||
// return package.InputPackageFile.ToSemanticVersion();
|
||||
//}
|
||||
|
||||
public static SemanticVersion ToSemanticVersion(this string fileName)
|
||||
{
|
||||
var name = _suffixRegex.Replace(fileName, "");
|
||||
var version = _versionRegex.Match(name).Value;
|
||||
return new SemanticVersion(version);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace Squirrel.Tests.Legacy
|
||||
namespace Squirrel.Tests.OldSquirrel
|
||||
{
|
||||
/// <summary>
|
||||
/// A hybrid implementation of SemVer that supports semantic versioning as described at http://semver.org while not strictly enforcing it to
|
||||
@@ -118,7 +120,7 @@ namespace Squirrel.Tests.Legacy
|
||||
public static SemanticVersion Parse(string version)
|
||||
{
|
||||
if (String.IsNullOrEmpty(version)) {
|
||||
throw new ArgumentException("Argument_Cannot_Be_Null_Or_Empty");
|
||||
throw new ArgumentException("Argument_Cannot_Be_Null_Or_Empty", "version");
|
||||
}
|
||||
|
||||
SemanticVersion semVer;
|
||||
@@ -187,7 +189,7 @@ namespace Squirrel.Tests.Legacy
|
||||
}
|
||||
SemanticVersion other = obj as SemanticVersion;
|
||||
if (other == null) {
|
||||
throw new ArgumentException("TypeMustBeASemanticVersion");
|
||||
throw new ArgumentException("TypeMustBeASemanticVersion", "obj");
|
||||
}
|
||||
return CompareTo(other);
|
||||
}
|
||||
21
test/Squirrel.Tests/OldSquirrel/Utility.cs
Normal file
21
test/Squirrel.Tests/OldSquirrel/Utility.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Squirrel.Tests.OldSquirrel
|
||||
{
|
||||
internal static class Utility
|
||||
{
|
||||
public static bool IsHttpUrl(string urlOrPath)
|
||||
{
|
||||
var uri = default(Uri);
|
||||
if (!Uri.TryCreate(urlOrPath, UriKind.Absolute, out uri)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,49 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using NuGet.Versioning;
|
||||
using Squirrel.Tests.TestHelpers;
|
||||
using Xunit;
|
||||
using OldReleaseEntry = Squirrel.Tests.OldSquirrel.ReleaseEntry;
|
||||
using OldSemanticVersion = Squirrel.Tests.OldSquirrel.SemanticVersion;
|
||||
|
||||
namespace Squirrel.Tests
|
||||
{
|
||||
public class ReleaseEntryTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(@"MyCoolApp-1.0-full.nupkg", "MyCoolApp", "1.0", "")]
|
||||
[InlineData(@"MyCoolApp-1.0.0-full.nupkg", "MyCoolApp", "1.0.0", "")]
|
||||
[InlineData(@"MyCoolApp-1.0.0-delta.nupkg", "MyCoolApp", "1.0.0", "")]
|
||||
[InlineData(@"MyCoolApp-1.0.0-win-x64-full.nupkg", "MyCoolApp", "1.0.0", "win-x64")]
|
||||
[InlineData(@"MyCoolApp-123.456.789-win-x64-full.nupkg", "MyCoolApp", "123.456.789", "win-x64")]
|
||||
[InlineData(@"MyCoolApp-123.456.789-hello-win-x64-full.nupkg", "MyCoolApp", "123.456.789", "hello-win-x64")]
|
||||
public void NewEntryCanRoundTripToOldSquirrel(string fileName, string id, string version, string metadata)
|
||||
{
|
||||
var size = 80396;
|
||||
var sha = "14db31d2647c6d2284882a2e101924a9c409ee67";
|
||||
var re = new ReleaseEntry(sha, fileName, size, null, null, null);
|
||||
StringBuilder file = new StringBuilder();
|
||||
file.AppendLine(re.EntryAsString);
|
||||
|
||||
var parsed = OldReleaseEntry.ParseReleaseFile(file.ToString());
|
||||
Assert.True(parsed.Count() == 1);
|
||||
|
||||
var oldEntry = parsed.First();
|
||||
|
||||
Assert.Equal(fileName, oldEntry.Filename);
|
||||
Assert.Equal(id, oldEntry.PackageName);
|
||||
Assert.Equal(size, oldEntry.Filesize);
|
||||
Assert.Equal(sha, oldEntry.SHA1);
|
||||
Assert.Null(oldEntry.BaseUrl);
|
||||
Assert.Null(oldEntry.Query);
|
||||
Assert.True(oldEntry.Version.Version == OldSemanticVersion.Parse(version).Version);
|
||||
Assert.Equal(oldEntry.Version.SpecialVersion, metadata);
|
||||
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(@"94689fede03fed7ab59c24337673a27837f0c3ec MyCoolApp-1.0.nupkg 1004502", "MyCoolApp-1.0.nupkg", 1004502, null, null)]
|
||||
[InlineData(@"3a2eadd15dd984e4559f2b4d790ec8badaeb6a39 MyCoolApp-1.1.nupkg 1040561", "MyCoolApp-1.1.nupkg", 1040561, null, null)]
|
||||
@@ -21,12 +56,12 @@ namespace Squirrel.Tests
|
||||
{
|
||||
var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry);
|
||||
|
||||
Assert.Equal(fileName, fixture.Filename);
|
||||
Assert.Equal(fileName, fixture.OriginalFilename);
|
||||
Assert.Equal(fileSize, fixture.Filesize);
|
||||
Assert.Equal(baseUrl, fixture.BaseUrl);
|
||||
Assert.Equal(query, fixture.Query);
|
||||
|
||||
var old = Legacy.ReleaseEntry.ParseReleaseEntry(releaseEntry);
|
||||
var old = OldReleaseEntry.ParseReleaseEntry(releaseEntry);
|
||||
Assert.Equal(fileName, old.Filename);
|
||||
Assert.Equal(fileSize, old.Filesize);
|
||||
Assert.Equal(baseUrl, old.BaseUrl);
|
||||
@@ -40,7 +75,7 @@ namespace Squirrel.Tests
|
||||
public void ParseValidReleaseEntryLinesWithDots(string releaseEntry, string packageName)
|
||||
{
|
||||
var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry);
|
||||
Assert.Equal(packageName, fixture.PackageName);
|
||||
Assert.Equal(packageName, fixture.PackageId);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -50,7 +85,7 @@ namespace Squirrel.Tests
|
||||
public void ParseValidReleaseEntryLinesWithDashes(string releaseEntry, string packageName)
|
||||
{
|
||||
var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry);
|
||||
Assert.Equal(packageName, fixture.PackageName);
|
||||
Assert.Equal(packageName, fixture.PackageId);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
@@ -106,10 +141,7 @@ namespace Squirrel.Tests
|
||||
[InlineData("0600000000000000000000000000000000000000 MyCoolApp-1.2.3.4-beta1.nupkg 123", 1, 2, 3, 4, "beta1", false)]
|
||||
[InlineData("0700000000000000000000000000000000000000 MyCoolApp-1.2.3.4-beta1-full.nupkg 123", 1, 2, 3, 4, "beta1", false)]
|
||||
[InlineData("0800000000000000000000000000000000000000 MyCoolApp-1.2.3.4-beta1-delta.nupkg 123", 1, 2, 3, 4, "beta1", true)]
|
||||
[InlineData("0900000000000000000000000000000000000000 MyCoolApp-1.2.3-beta1-win7-x64.nupkg 123", 1, 2, 3, 0, "beta1-win7-x64", false)]
|
||||
[InlineData("0010000000000000000000000000000000000000 MyCoolApp-1.2.3-beta1-win7-x64-full.nupkg 123", 1, 2, 3, 0, "beta1-win7-x64", false)]
|
||||
[InlineData("0020000000000000000000000000000000000000 MyCoolApp-1.2.3-beta1-win7-x64-delta.nupkg 123", 1, 2, 3, 0, "beta1-win7-x64", true)]
|
||||
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-beta.22-win7-x64-full.nupkg 123", 1, 2, 3, 0, "beta1-win7-x64", false)]
|
||||
|
||||
public void ParseVersionTest(string releaseEntry, int major, int minor, int patch, int revision, string prerelease, bool isDelta)
|
||||
{
|
||||
var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry);
|
||||
@@ -117,11 +149,48 @@ namespace Squirrel.Tests
|
||||
Assert.Equal(new NuGetVersion(major, minor, patch, revision, prerelease, null), fixture.Version);
|
||||
Assert.Equal(isDelta, fixture.IsDelta);
|
||||
|
||||
var old = Legacy.ReleaseEntry.ParseReleaseEntry(releaseEntry);
|
||||
var old = OldReleaseEntry.ParseReleaseEntry(releaseEntry);
|
||||
Assert.Equal(new NuGetVersion(major, minor, patch, revision, prerelease, null), new NuGetVersion(old.Version.ToString()));
|
||||
Assert.Equal(isDelta, old.IsDelta);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("0900000000000000000000000000000000000000 MyCoolApp-1.2.3-beta1-win7-x64.nupkg 123", 1, 2, 3, 0, "beta1", "win7-x64", false)]
|
||||
[InlineData("0010000000000000000000000000000000000000 MyCoolApp-1.2.3-beta1-win7-x64-full.nupkg 123", 1, 2, 3, 0, "beta1", "win7-x64", false)]
|
||||
[InlineData("0020000000000000000000000000000000000000 MyCoolApp-1.2.3-beta1-win7-x64-delta.nupkg 123", 1, 2, 3, 0, "beta1", "win7-x64", true)]
|
||||
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-osx-full.nupkg 123", 1, 2, 3, 0, "", "osx", false)]
|
||||
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-osx-arm64-full.nupkg 123", 1, 2, 3, 0, "", "osx-arm64", false)]
|
||||
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-hello-osx-arm64-full.nupkg 123", 1, 2, 3, 0, "hello", "osx-arm64", false)]
|
||||
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-x86-full.nupkg 123", 1, 2, 3, 0, "", "x86", false)]
|
||||
public void ParseVersionWithRidTest(string releaseEntry, int major, int minor, int patch, int revision, string prerelease, string rid, bool isDelta)
|
||||
{
|
||||
var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry);
|
||||
Assert.Equal(new NuGetVersion(major, minor, patch, revision, prerelease, null), fixture.Version);
|
||||
Assert.Equal(isDelta, fixture.IsDelta);
|
||||
if (!String.IsNullOrEmpty(rid))
|
||||
Assert.Equal(RID.Parse(rid), fixture.Rid);
|
||||
|
||||
var old = OldReleaseEntry.ParseReleaseEntry(releaseEntry);
|
||||
var legacyPre = !String.IsNullOrEmpty(prerelease) && !String.IsNullOrEmpty(rid) ? $"{prerelease}-{rid}" : String.IsNullOrEmpty(prerelease) ? rid : prerelease;
|
||||
Assert.Equal(new NuGetVersion(major, minor, patch, revision, legacyPre, null), new NuGetVersion(old.Version.ToString()));
|
||||
Assert.Equal(isDelta, old.IsDelta);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-beta.22-win7-x64-full.nupkg 123", 1, 2, 3, 0, "beta.22", "win7-x64", false)]
|
||||
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-beta.22-x64-full.nupkg 123", 1, 2, 3, 0, "beta.22", "x64", false)]
|
||||
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-beta.22-win-full.nupkg 123", 1, 2, 3, 0, "beta.22", "win", false)]
|
||||
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-hello.55-osx-arm64-full.nupkg 123", 1, 2, 3, 0, "hello.55", "osx-arm64", false)]
|
||||
[InlineData("0030000000000000000000000000000000000000 MyCoolApp-1.2.3-hello.55-full.nupkg 123", 1, 2, 3, 0, "hello.55", "", false)]
|
||||
public void ParseVersionWithSemVer2(string releaseEntry, int major, int minor, int patch, int revision, string prerelease, string rid, bool isDelta)
|
||||
{
|
||||
var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry);
|
||||
Assert.Equal(new NuGetVersion(major, minor, patch, revision, prerelease, null), fixture.Version);
|
||||
Assert.Equal(isDelta, fixture.IsDelta);
|
||||
if (!String.IsNullOrEmpty(rid))
|
||||
Assert.Equal(RID.Parse(rid), fixture.Rid);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("0000000000000000000000000000000000000000 MyCool-App-1.2.nupkg 123", "MyCool-App")]
|
||||
[InlineData("0000000000000000000000000000000000000000 MyCool_App-1.2-full.nupkg 123", "MyCool_App")]
|
||||
@@ -144,20 +213,20 @@ namespace Squirrel.Tests
|
||||
public void CheckPackageName(string releaseEntry, string expected)
|
||||
{
|
||||
var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry);
|
||||
Assert.Equal(expected, fixture.PackageName);
|
||||
Assert.Equal(expected, fixture.PackageId);
|
||||
|
||||
var old = Legacy.ReleaseEntry.ParseReleaseEntry(releaseEntry);
|
||||
var old = OldReleaseEntry.ParseReleaseEntry(releaseEntry);
|
||||
Assert.Equal(expected, old.PackageName);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2.nupkg 123 # 10%", 1, 2, 0, 0, "", false, 0.1f)]
|
||||
[InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-full.nupkg 123 # 90%", 1, 2, 0, 0, "", false, 0.9f)]
|
||||
[InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-delta.nupkg 123", 1, 2, 0, 0, "", true, null)]
|
||||
[InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-delta.nupkg 123 # 5%", 1, 2, 0, 0, "", true, 0.05f)]
|
||||
[InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-win7-x64-delta.nupkg 123", 1, 2, 0, 0, "win7-x64", true, null)]
|
||||
[InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-win7-x64-full.nupkg 123 # 5%", 1, 2, 0, 0, "win7-x64", false, 0.05f)]
|
||||
public void ParseStagingPercentageTest(string releaseEntry, int major, int minor, int patch, int revision, string prerelease, bool isDelta, float? stagingPercentage)
|
||||
[InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2.nupkg 123 # 10%", 1, 2, 0, 0, "", "", false, 0.1f)]
|
||||
[InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-full.nupkg 123 # 90%", 1, 2, 0, 0, "", "", false, 0.9f)]
|
||||
[InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-delta.nupkg 123", 1, 2, 0, 0, "", "", true, null)]
|
||||
[InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-delta.nupkg 123 # 5%", 1, 2, 0, 0, "", "", true, 0.05f)]
|
||||
[InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-win7-x64-delta.nupkg 123", 1, 2, 0, 0, "", "win7-x64", true, null)]
|
||||
[InlineData("0000000000000000000000000000000000000000 MyCoolApp-1.2-win7-x64-full.nupkg 123 # 5%", 1, 2, 0, 0, "", "win7-x64", false, 0.05f)]
|
||||
public void ParseStagingPercentageTest(string releaseEntry, int major, int minor, int patch, int revision, string prerelease, string rid, bool isDelta, float? stagingPercentage)
|
||||
{
|
||||
var fixture = ReleaseEntry.ParseReleaseEntry(releaseEntry);
|
||||
|
||||
@@ -170,8 +239,9 @@ namespace Squirrel.Tests
|
||||
Assert.Null(fixture.StagingPercentage);
|
||||
}
|
||||
|
||||
var old = Legacy.ReleaseEntry.ParseReleaseEntry(releaseEntry);
|
||||
Assert.Equal(new NuGetVersion(major, minor, patch, revision, prerelease, null), new NuGetVersion(old.Version.ToString()));
|
||||
var old = OldReleaseEntry.ParseReleaseEntry(releaseEntry);
|
||||
var legacyPre = !String.IsNullOrEmpty(prerelease) && !String.IsNullOrEmpty(rid) ? $"{prerelease}-{rid}" : String.IsNullOrEmpty(prerelease) ? rid : prerelease;
|
||||
Assert.Equal(new NuGetVersion(major, minor, patch, revision, legacyPre, null), new NuGetVersion(old.Version.ToString()));
|
||||
Assert.Equal(isDelta, old.IsDelta);
|
||||
|
||||
if (stagingPercentage.HasValue) {
|
||||
@@ -433,7 +503,7 @@ namespace Squirrel.Tests
|
||||
var entries = ReleaseEntry.ParseReleaseFile(_ridReleaseEntries);
|
||||
|
||||
var e = Utility.FindLatestFullVersion(entries, RID.Parse("win-x86"));
|
||||
Assert.Equal("MyApp-1.4-win-x86.nupkg", e.Filename);
|
||||
Assert.Equal("MyApp-1.4-win-x86.nupkg", e.OriginalFilename);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -450,7 +520,24 @@ namespace Squirrel.Tests
|
||||
var entries = ReleaseEntry.ParseReleaseFile(_ridReleaseEntries);
|
||||
|
||||
var e = Utility.FindLatestFullVersion(entries, RID.Parse("win-x86"));
|
||||
Assert.Equal("MyApp-1.3-win.nupkg", e.Filename);
|
||||
Assert.Equal("MyApp-1.3-win.nupkg", e.OriginalFilename);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FindCurrentVersionWithExactRidMatchOnlyArchitecture()
|
||||
{
|
||||
string _ridReleaseEntries = """
|
||||
0000000000000000000000000000000000000000 MyApp-1.3-win-x86.nupkg 123
|
||||
0000000000000000000000000000000000000000 MyApp-1.4.nupkg 123
|
||||
0000000000000000000000000000000000000000 MyApp-1.4-win-x64.nupkg 123
|
||||
0000000000000000000000000000000000000000 MyApp-1.4-win.nupkg 123
|
||||
0000000000000000000000000000000000000000 MyApp-1.4-osx-x86.nupkg 123
|
||||
""";
|
||||
|
||||
var entries = ReleaseEntry.ParseReleaseFile(_ridReleaseEntries);
|
||||
|
||||
var e = Utility.FindLatestFullVersion(entries, RID.Parse("win-x86"));
|
||||
Assert.Equal("MyApp-1.3-win.nupkg", e.OriginalFilename);
|
||||
}
|
||||
|
||||
static string MockReleaseEntry(string name, float? percentage = null)
|
||||
|
||||
@@ -3,25 +3,10 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Description>Squirrel.Tests</Description>
|
||||
<Title>Squirrel.Tests</Title>
|
||||
<IsPackable>false</IsPackable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<IsTest>true</IsTest>
|
||||
<NoWarn>CS1998,xUnit2015,xUnit2017,xUnit2005,xUnit2009,xUnit2013,xUnit2004</NoWarn>
|
||||
<SignAssembly>True</SignAssembly>
|
||||
<AssemblyOriginatorKeyFile>..\..\Squirrel.snk</AssemblyOriginatorKeyFile>
|
||||
<NoWarn>$(NoWarn);CA2007</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="xunit" Version="2.6.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.5" PrivateAssets="All" />
|
||||
<PackageReference Include="System.IO.Packaging" Version="8.0.0" />
|
||||
<PackageReference Include="Xunit.SkippableFact" Version="1.4.13" />
|
||||
<PackageReference Include="Divergic.Logging.Xunit" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user