diff --git a/.vscode/launch.json b/.vscode/launch.json index 4065eda..e179e1e 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -27,8 +27,8 @@ "name": "web", "type": "coreclr", "request": "launch", - "preLaunchTask": "publish", - "program": "${workspaceFolder}/artifacts/isnd.dll", + "preLaunchTask": "build", + "program": "${workspaceFolder}/src/isnd/bin/Debug/netcoreapp2.1/isnd.dll", "args": [], "cwd": "${workspaceFolder}/src/isnd", "stopAtEntry": false, diff --git a/omnisharp.json b/omnisharp.json new file mode 100644 index 0000000..5df81ef --- /dev/null +++ b/omnisharp.json @@ -0,0 +1,22 @@ +{ + "dotnet": { + "enabled": false + }, + "msbuild": { + "enabled": true + }, + "Dnx": { + "enabled": false + }, + "Script": { + "enabled": false + }, + "fileOptions": { + "systemExcludeSearchPatterns": [ + "**/bin/**/*", + "**/obj/**/*", + "**/node_modules/**/*" + ], + "userExcludeSearchPatterns": [] + } +} diff --git a/src/isnd/Data/Catalog/PackageRegistrationIndexViewModel.cs b/src/isnd/Data/Catalog/PackageRegistrationIndexViewModel.cs index 02df87a..f528e35 100644 --- a/src/isnd/Data/Catalog/PackageRegistrationIndexViewModel.cs +++ b/src/isnd/Data/Catalog/PackageRegistrationIndexViewModel.cs @@ -4,6 +4,10 @@ namespace isnd.Data.Catalog { public class PackageRegistrationIndexQuery : RegistrationPageIndex { + public PackageRegistrationIndexQuery(string id) : base(id) + { + } + [JsonProperty("prerelease")] public bool Prerelease { get; set; } diff --git a/src/isnd/Data/Catalog/PageRef.cs b/src/isnd/Data/Catalog/PageRef.cs deleted file mode 100644 index 0fd5e25..0000000 --- a/src/isnd/Data/Catalog/PageRef.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using isnd.Interfaces; -using Newtonsoft.Json; - -namespace isnd.Data.Catalog -{ - public class PageRef : IObject - { - /// - /// Page Url - /// - /// - [JsonProperty("@id")] - public string Id { get; set; } - - /// - /// Page entry count - /// - /// - [JsonProperty("count")] - public int Count { get; set; } - - [JsonProperty("commitId")] - public string CommitId { get; set; } - - [JsonProperty("commitTimeStamp")] - public DateTime CommitTimeStamp { get; set; } - - } - - -} \ No newline at end of file diff --git a/src/isnd/Data/Catalog/RegistratioinLeave.cs b/src/isnd/Data/Catalog/RegistratioinLeave.cs index 3cf85f8..65c2b93 100644 --- a/src/isnd/Data/Catalog/RegistratioinLeave.cs +++ b/src/isnd/Data/Catalog/RegistratioinLeave.cs @@ -3,6 +3,10 @@ using Newtonsoft.Json; namespace isnd.Data.Catalog { + /// + /// Hosts a catalog entry, + /// the atomic content reference + /// public class RegistrationLeaf { /* diff --git a/src/isnd/Data/Catalog/RegistrationPage.cs b/src/isnd/Data/Catalog/RegistrationPage.cs index cce9867..66ac9c4 100644 --- a/src/isnd/Data/Catalog/RegistrationPage.cs +++ b/src/isnd/Data/Catalog/RegistrationPage.cs @@ -1,24 +1,18 @@ using System; +using System.Collections.Generic; using Newtonsoft.Json; namespace isnd.Data.Catalog { - public class RegistrationPage + public class RegistrationPage { - - /// - /// The URL to the registration page - /// - /// - [JsonProperty("@id"), JsonRequired] - public string Id { get; set; } - - /// - /// The number of registration leaves in the page - /// - /// - [JsonProperty("count"), JsonRequired] - public int Count { get; set; } + [JsonProperty("@id")] + [JsonRequired] + public string Id { get; } + public RegistrationPage (string id) + { + Id = id; + } /// /// no The array of registration leaves and their associate metadata @@ -26,7 +20,7 @@ namespace isnd.Data.Catalog /// [JsonProperty("items")] - public RegistrationLeaf[] Items { get; set; } + public List Items { get; set; } /// /// The highest SemVer 2.0.0 version in the page (inclusive) /// @@ -47,5 +41,9 @@ namespace isnd.Data.Catalog [JsonProperty("parent")] public string Parent { get; set; } + [JsonProperty("count")] + public int Count { get; internal set; } + public string CommitId { get; internal set; } + public DateTime CommitTimeStamp { get; internal set; } } } \ No newline at end of file diff --git a/src/isnd/Data/Catalog/RegistrationPageIndex.cs b/src/isnd/Data/Catalog/RegistrationPageIndex.cs index bce162e..f08b2e3 100644 --- a/src/isnd/Data/Catalog/RegistrationPageIndex.cs +++ b/src/isnd/Data/Catalog/RegistrationPageIndex.cs @@ -1,13 +1,38 @@ using Newtonsoft.Json; +using System.Collections.Generic; namespace isnd.Data.Catalog { public class RegistrationPageIndex { + /// + /// Page Url + /// + /// + [JsonProperty("@id")] + public string Id { get; set; } + public RegistrationPageIndex(string id) + { + Id = id; + Items = new List(); + } + + public RegistrationPageIndex(IEnumerable pages) + { + Items = new List(pages); + } + + public RegistrationPageIndex(string id, IEnumerable leaves) : this(id) + { + // leaves; + } + [JsonProperty("count")] - public int Count { get => Items?.Length ?? 0; } + public int Count { get => Items?.Count ?? 0; } [JsonProperty("items")] - public RegistrationPage[] Items { get; set; } + public List Items { get; set; } + + public string CommitId { get; set; } } } \ No newline at end of file diff --git a/src/isnd/Data/Packages/Catalog/CatalogIndex.cs b/src/isnd/Data/Packages/Catalog/CatalogIndex.cs deleted file mode 100644 index 0e7976a..0000000 --- a/src/isnd/Data/Packages/Catalog/CatalogIndex.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; -using isnd.Interfaces; -using isnd.Data.Catalog; - -namespace isnd.Data.Packages.Catalog -{ - public class CatalogIndex : IObject - { - [JsonProperty("@id")] - public string Id { get; set ; } - - [JsonProperty("items")] - public List Items { get; set; } - - - [JsonProperty("count")] - public int Count { get => Items?.Count ?? 0; } - public string CommitId { get; set; } - public DateTime CommitTimeStamp { get; set; } - - } - - -} \ No newline at end of file diff --git a/src/isnd/Data/Packages/Package.cs b/src/isnd/Data/Packages/Package.cs index a3f15fd..6940003 100644 --- a/src/isnd/Data/Packages/Package.cs +++ b/src/isnd/Data/Packages/Package.cs @@ -57,7 +57,7 @@ namespace isnd.Data.Packages var v = Versions.First(); RegistrationLeaf leave = new RegistrationLeaf { - Id = bid + Id + ".json", + Id = bid + Id + "/" + v.FullString + ".json", PackageContent = v.NugetLink, Entry = new CatalogEntry { diff --git a/src/isnd/Helpers/PackageVersionHelpers.cs b/src/isnd/Helpers/PackageVersionHelpers.cs index b4845f2..6c21437 100644 --- a/src/isnd/Helpers/PackageVersionHelpers.cs +++ b/src/isnd/Helpers/PackageVersionHelpers.cs @@ -18,7 +18,7 @@ namespace isnd.Helpers return v.Package.OwnerId == userId; } - public static RegistrationPage[] CreateRegistrationPages(this IEnumerable leaves, + public static RegistrationPageIndex CreateRegistrationPages(this IEnumerable leaves, string bid) { List pages = new List(); @@ -28,19 +28,18 @@ namespace isnd.Helpers var lbi = leaves.Where(l=>l.Entry.Id == id).OrderBy(l=> new Version(l.Entry.version)); var latest = new Version(lbi.Last().Entry.version); - pages.Add(new RegistrationPage - { - Id = bid + id + "/" + latest.Major + "." + pages.Add(new RegistrationPage(bid + id + "/" + latest.Major + "." + latest.Minor + "." - + latest.Build, + + latest.Build) + { Count = lbi.Count(), Lower = new Version(lbi.First().Entry.version), Upper = latest, - Items = lbi.ToArray(), + Items = lbi.ToList(), Parent = bid + id + "/" + ApiConfig.IndexDotJson, }); } - return pages.ToArray(); + return new RegistrationPageIndex(pages); } } } \ No newline at end of file diff --git a/src/isnd/Interfaces/IPackageManager.cs b/src/isnd/Interfaces/IPackageManager.cs index d5de83f..dc112c0 100644 --- a/src/isnd/Interfaces/IPackageManager.cs +++ b/src/isnd/Interfaces/IPackageManager.cs @@ -18,7 +18,6 @@ namespace isnd.Interfaces string CatalogBaseUrl { get; } AutoCompleteResult AutoComplete(string pkgid, int skip, int take, bool prerelease = false, string packageType = null); - CatalogIndex GetCatalogIndex(); string[] GetVersions(string pkgid, NuGetVersion parsedVersion, bool prerelease = false, string packageType = null, int skip = 0, int take = 25); RegistrationPageIndex SearchByName(string query, int skip, int take, bool prerelease = false, string packageType = null); IEnumerable GetResources(IUnleash unleashĈlient); @@ -28,6 +27,8 @@ namespace isnd.Interfaces Task GetPackageAsync(string pkgid, string version, string type); IEnumerable GetCatalogLeaf(string pkgId, string semver, string pkgType); IEnumerable SearchById(string pkgId, string semver, string pkgType); + + RegistrationPageIndex GetCatalogIndex(); } } \ No newline at end of file diff --git a/src/isnd/Services/PackageManager.cs b/src/isnd/Services/PackageManager.cs index aae083b..c78ba98 100644 --- a/src/isnd/Services/PackageManager.cs +++ b/src/isnd/Services/PackageManager.cs @@ -139,10 +139,8 @@ namespace isnd.Services var pkgs = scope.Skip(skip).Take(take).ToArray(); string bid = $"{extUrl}v3.4.0/{ApiConfig.Registration}/"; var leaves = pkgs.Select(p => p.ToLeave(bid)); - return new RegistrationPageIndex - { - Items = leaves.CreateRegistrationPages(bid) - }; + + return new RegistrationPageIndex(bid, leaves); } public AutoCompleteResult AutoComplete(string id, @@ -184,15 +182,15 @@ namespace isnd.Services .Skip(skip).Take(take).ToArray(); } - public static CatalogIndex CurrentCatalogIndex { get; protected set; } - public static List CurrentCatalogPages { get; protected set; } + public static RegistrationPageIndex CurrentCatalogIndex { get; protected set; } + public static List CurrentCatalogPages { get; protected set; } public string CatalogBaseUrl => extUrl; private IsndSettings isndSettings; private string extUrl; - public virtual CatalogIndex GetCatalogIndex() + public virtual RegistrationPageIndex GetCatalogIndex() { if (CurrentCatalogIndex == null) { @@ -207,35 +205,28 @@ namespace isnd.Services var oldIndex = CurrentCatalogIndex; var oldPages = CurrentCatalogPages; string baseid = extUrl + ApiConfig.Catalog; + string bidreg = $"{extUrl}v3.4.0/{ApiConfig.Registration}/"; string basepageid = extUrl + ApiConfig.CatalogPage; - CurrentCatalogIndex = new CatalogIndex - { - Id = baseid, - Items = new List() - }; - CurrentCatalogPages = new List(); + CurrentCatalogIndex = new RegistrationPageIndex(baseid); + CurrentCatalogPages = new List(); var scope = dbContext.Commits.OrderBy(c => c.TimeStamp); - PageRef pageRef = null; - Page page = null; + RegistrationPage page = null; i = isndSettings.CatalogPageLen; foreach (var commit in scope) { if (i >= this.isndSettings.CatalogPageLen) { - page = new Page + page = new RegistrationPage(basepageid + "-" + p++) { - Id = basepageid + "-" + p++, Parent = baseid, CommitId = commit.CommitId, - CommitTimeStamp = commit.CommitTimeStamp, - Items = new List() + CommitTimeStamp = commit.CommitTimeStamp }; CurrentCatalogPages.Add(page); - pageRef = new PageRef + var pageRef = new RegistrationPage(page.Id) { - Id = page.Id, CommitId = commit.CommitId, CommitTimeStamp = commit.CommitTimeStamp }; @@ -247,21 +238,14 @@ namespace isnd.Services .Include(pkg => pkg.LatestVersion) .Where( pkg => pkg.Versions.Count(v => v.CommitId == commit.CommitId) > 0 - ); + ).GroupBy((q)=> q.Id); // pkg.Versions.OrderByDescending(vi => vi.CommitNId).First().FullString - foreach (var pkg in validPkgs) + foreach (var pkgid in validPkgs) { - var v = pkg.Versions. - Where(cv => cv.CommitId == commit.CommitId) - .OrderByDescending(vc => vc.CommitNId).First(); - - StringBuilder refid = new StringBuilder(extUrl); - refid.AppendFormat("{0}/{1}/{2}", ApiConfig.CatalogLeaf, v.PackageId - , v.FullString); - if (v.Type != null) - refid.AppendFormat("/{0}", v.Type); - - var pkgref = new PackageRef + StringBuilder refid = new StringBuilder(bidreg); + refid.AppendFormat("{0}/", + pkgid.Key); + /* var pkgref = new PackageRef { Version = v.FullString, LastCommit = v.LatestCommit, @@ -272,8 +256,9 @@ namespace isnd.Services RefType = v.LatestCommit.Action == PackageAction.PublishPackage ? "nuget:PackageDetails" : "nuget:PackageDelete" - }; - page.Items.Add(pkgref); + }; */ + foreach (var pkgv in pkgid) + page.Items.Add(pkgv.ToLeave(bidreg)); } reason = commit; i++; diff --git a/src/isnd/Views/Packages/Index.cshtml b/src/isnd/Views/Packages/Index.cshtml index ae6ced1..1d8d4c6 100644 --- a/src/isnd/Views/Packages/Index.cshtml +++ b/src/isnd/Views/Packages/Index.cshtml @@ -25,10 +25,10 @@ - @Html.DisplayNameFor(model => model.Items[0].Items[0].Id) + @Html.DisplayNameFor(model => model.Items[0].Id) - @Html.DisplayNameFor(model => model.Items[0].Items[0].Entry.Description) + @Html.DisplayNameFor(model => model.Items[0].CommitId)