|
|
@ -164,22 +164,20 @@ namespace isnd.Services
|
|
|
|
i = isndSettings.CatalogPageLen;
|
|
|
|
i = isndSettings.CatalogPageLen;
|
|
|
|
foreach (var commit in scope)
|
|
|
|
foreach (var commit in scope)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
var validPkgs = (await dbContext.Packages
|
|
|
|
var validPkgs = (await dbContext.Packages
|
|
|
|
.Include(po => po.Owner)
|
|
|
|
.Include(po => po.Owner)
|
|
|
|
.Include(pkg => pkg.Versions)
|
|
|
|
.Include(pkg => pkg.Versions)
|
|
|
|
.Include(pkg => pkg.LatestCommit)
|
|
|
|
.Include(pkg => pkg.LatestCommit)
|
|
|
|
.ToArrayAsync())
|
|
|
|
.ToArrayAsync())
|
|
|
|
.GroupBy((q) => q.Id);
|
|
|
|
.GroupBy((q) => q.Id);
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var pkgIdGroup in validPkgs)
|
|
|
|
foreach (var pkgIdGroup in validPkgs)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
CatalogPage page = index.Items.FirstOrDefault
|
|
|
|
RegistrationPage page = index.Items.FirstOrDefault
|
|
|
|
(p => p.GetPackageId() == pkgIdGroup.Key);
|
|
|
|
(p => p.GetPackageId() == pkgIdGroup.Key);
|
|
|
|
if (page == null)
|
|
|
|
if (page == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
page = new CatalogPage(pkgIdGroup.Key, apiBase);
|
|
|
|
page = new RegistrationPage(pkgIdGroup.Key, apiBase);
|
|
|
|
index.Items.Add(page);
|
|
|
|
index.Items.Add(page);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -225,12 +223,12 @@ namespace isnd.Services
|
|
|
|
return await dbContext.PackageVersions.SingleOrDefaultAsync(
|
|
|
|
return await dbContext.PackageVersions.SingleOrDefaultAsync(
|
|
|
|
v => v.PackageId == pkgId &&
|
|
|
|
v => v.PackageId == pkgId &&
|
|
|
|
v.FullString == version &&
|
|
|
|
v.FullString == version &&
|
|
|
|
v.Type == type
|
|
|
|
(type==null || v.Type == type)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<Data.Catalog.RegistrationLeave> GetCatalogEntryAsync
|
|
|
|
public async Task<Data.Catalog.RegistrationLeaf> GetCatalogEntryAsync
|
|
|
|
(string pkgId, string semver, string pkgType = null)
|
|
|
|
(string pkgId, string semver, string pkgType = "Dependency")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var version = await dbContext.PackageVersions
|
|
|
|
var version = await dbContext.PackageVersions
|
|
|
|
.Include(v => v.Package)
|
|
|
|
.Include(v => v.Package)
|
|
|
@ -241,13 +239,12 @@ namespace isnd.Services
|
|
|
|
.Where(v => v.PackageId == pkgId
|
|
|
|
.Where(v => v.PackageId == pkgId
|
|
|
|
&& v.FullString == semver
|
|
|
|
&& v.FullString == semver
|
|
|
|
&& v.LatestCommit != null
|
|
|
|
&& v.LatestCommit != null
|
|
|
|
|
|
|
|
&& (pkgType == null || pkgType == v.Type)
|
|
|
|
).SingleOrDefaultAsync();
|
|
|
|
).SingleOrDefaultAsync();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var g in version.DependencyGroups)
|
|
|
|
foreach (var g in version.DependencyGroups)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
g.Dependencies = dbContext.Dependencies.Where(d => d.DependencyGroupId == g.Id).ToList();
|
|
|
|
g.Dependencies = dbContext.Dependencies.Where(d => d.DependencyGroupId == g.Id).ToList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return version.ToPackage(apiBase);
|
|
|
|
return version.ToPackage(apiBase);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -257,14 +254,14 @@ namespace isnd.Services
|
|
|
|
PackageVersion packageVersion = await dbContext.PackageVersions
|
|
|
|
PackageVersion packageVersion = await dbContext.PackageVersions
|
|
|
|
.Include(pv => pv.Package)
|
|
|
|
.Include(pv => pv.Package)
|
|
|
|
.FirstOrDefaultAsync(m => m.PackageId == id
|
|
|
|
.FirstOrDefaultAsync(m => m.PackageId == id
|
|
|
|
&& m.FullString == lower && m.Type == type);
|
|
|
|
&& m.FullString == lower && (type==null || m.Type == type));
|
|
|
|
if (packageVersion == null) return null;
|
|
|
|
if (packageVersion == null) return null;
|
|
|
|
if (packageVersion.Package.OwnerId != uid) return null;
|
|
|
|
if (packageVersion.Package.OwnerId != uid) return null;
|
|
|
|
return new PackageDeletionReport { Deleted = true, DeletedVersion = packageVersion };
|
|
|
|
return new PackageDeletionReport { Deleted = true, DeletedVersion = packageVersion };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public IEnumerable<Data.Catalog.RegistrationLeave> SearchCatalogEntriesById
|
|
|
|
public IEnumerable<Data.Catalog.RegistrationLeaf> SearchCatalogEntriesById
|
|
|
|
(string pkgId, string semver, string pkgType, bool preRelease)
|
|
|
|
(string pkgId, string semver, string pkgType, bool preRelease)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// PackageDependency
|
|
|
|
// PackageDependency
|
|
|
@ -294,7 +291,6 @@ namespace isnd.Services
|
|
|
|
public async Task<PackageRegistration> GetPackageRegistrationIndexAsync
|
|
|
|
public async Task<PackageRegistration> GetPackageRegistrationIndexAsync
|
|
|
|
(PackageRegistrationQuery query)
|
|
|
|
(PackageRegistrationQuery query)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// RegistrationPageIndexAndQuery
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(query.Query)) return null;
|
|
|
|
if (string.IsNullOrWhiteSpace(query.Query)) return null;
|
|
|
|
query.Query = query.Query.ToLower();
|
|
|
|
query.Query = query.Query.ToLower();
|
|
|
|
var scope = await dbContext.PackageVersions
|
|
|
|
var scope = await dbContext.PackageVersions
|
|
|
@ -305,7 +301,6 @@ namespace isnd.Services
|
|
|
|
if (scope == null) return null;
|
|
|
|
if (scope == null) return null;
|
|
|
|
if (scope.Length == 0) return null;
|
|
|
|
if (scope.Length == 0) return null;
|
|
|
|
string bid = $"{apiBase}{ApiConfig.Registration}";
|
|
|
|
string bid = $"{apiBase}{ApiConfig.Registration}";
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var version in scope)
|
|
|
|
foreach (var version in scope)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
version.DependencyGroups = dbContext.PackageDependencyGroups.Include(d => d.Dependencies)
|
|
|
|
version.DependencyGroups = dbContext.PackageDependencyGroups.Include(d => d.Dependencies)
|
|
|
@ -313,9 +308,7 @@ namespace isnd.Services
|
|
|
|
.ToList();
|
|
|
|
.ToList();
|
|
|
|
version.LatestCommit = dbContext.Commits.Single(c => c.Id == version.CommitNId);
|
|
|
|
version.LatestCommit = dbContext.Commits.Single(c => c.Id == version.CommitNId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return new PackageRegistration(apiBase, query.Query, scope);
|
|
|
|
return
|
|
|
|
|
|
|
|
new PackageRegistration(apiBase, query.Query, scope);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<PackageSearchResult> SearchPackageAsync(PackageRegistrationQuery query)
|
|
|
|
public async Task<PackageSearchResult> SearchPackageAsync(PackageRegistrationQuery query)
|
|
|
@ -325,19 +318,20 @@ namespace isnd.Services
|
|
|
|
query.Query = "";
|
|
|
|
query.Query = "";
|
|
|
|
|
|
|
|
|
|
|
|
var packages = await dbContext.Packages
|
|
|
|
var packages = await dbContext.Packages
|
|
|
|
.Include(g => g.Versions)
|
|
|
|
.Include(g => g.Versions).OrderBy(v=>v.CommitNId)
|
|
|
|
.Where(d => d.Id.StartsWith(query.Query)
|
|
|
|
.Where(d => d.Id.StartsWith(query.Query)
|
|
|
|
&& (query.Prerelease || d.Versions.Any(v => !v.IsPrerelease)))
|
|
|
|
&& (query.Prerelease || d.Versions.Any(v => !v.IsPrerelease)))
|
|
|
|
|
|
|
|
.Where(p=>p.Versions.Count>=0)
|
|
|
|
.Skip(query.Skip).Take(query.Take).ToArrayAsync();
|
|
|
|
.Skip(query.Skip).Take(query.Take).ToArrayAsync();
|
|
|
|
foreach (var package in packages)
|
|
|
|
foreach (var package in packages)
|
|
|
|
foreach (var version in package.Versions)
|
|
|
|
foreach (var version in package.Versions)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
version.DependencyGroups = dbContext.PackageDependencyGroups.Include(d => d.Dependencies)
|
|
|
|
version.DependencyGroups = dbContext.PackageDependencyGroups.Include(d => d.Dependencies)
|
|
|
|
.Where(d => d.PackageVersionFullString == version.FullString && d.PackageId == version.PackageId)
|
|
|
|
.Where(d => d.PackageVersionFullString == version.FullString && d.PackageId == version.PackageId)
|
|
|
|
|
|
|
|
|
|
|
|
.ToList();
|
|
|
|
.ToList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new PackageSearchResult(packages, apiBase, packages.Count());
|
|
|
|
return new PackageSearchResult(packages, apiBase, packages.Count());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<PackageVersion> PutPackageAsync(Stream packageStream, string ownerId)
|
|
|
|
public async Task<PackageVersion> PutPackageAsync(Stream packageStream, string ownerId)
|
|
|
@ -370,17 +364,14 @@ namespace isnd.Services
|
|
|
|
var frameWorks = (dependencies ?? frameworkReferences)
|
|
|
|
var frameWorks = (dependencies ?? frameworkReferences)
|
|
|
|
.Descendants().Where(x => x.Name.LocalName == "group")
|
|
|
|
.Descendants().Where(x => x.Name.LocalName == "group")
|
|
|
|
.Select(x => NewFrameworkDependencyGroup(x)).ToArray();
|
|
|
|
.Select(x => NewFrameworkDependencyGroup(x)).ToArray();
|
|
|
|
var types = "Package";
|
|
|
|
// FIXME default package type or null
|
|
|
|
|
|
|
|
var types = "Dependency";
|
|
|
|
pkgId = xMeta.Descendants().FirstOrDefault(x => x.Name.LocalName == "id")?.Value;
|
|
|
|
pkgId = xMeta.Descendants().FirstOrDefault(x => x.Name.LocalName == "id")?.Value;
|
|
|
|
string pkgVersion = xMeta.Descendants().FirstOrDefault(x => x.Name.LocalName == "version")?.Value;
|
|
|
|
string pkgVersion = xMeta.Descendants().FirstOrDefault(x => x.Name.LocalName == "version")?.Value;
|
|
|
|
|
|
|
|
|
|
|
|
if (!NuGetVersion.TryParse(pkgVersion, out nugetVersion))
|
|
|
|
if (!NuGetVersion.TryParse(pkgVersion, out nugetVersion))
|
|
|
|
throw new InvalidPackageException("metadata/version");
|
|
|
|
throw new InvalidPackageException("metadata/version");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string packageIdPath = Path.Combine(isndSettings.PackagesRootDir,
|
|
|
|
string packageIdPath = Path.Combine(isndSettings.PackagesRootDir,
|
|
|
|
pkgId);
|
|
|
|
pkgId);
|
|
|
|
pkgPath = Path.Combine(packageIdPath, nugetVersion.ToFullString());
|
|
|
|
pkgPath = Path.Combine(packageIdPath, nugetVersion.ToFullString());
|
|
|
@ -397,21 +388,20 @@ namespace isnd.Services
|
|
|
|
if (pkg != null)
|
|
|
|
if (pkg != null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Update
|
|
|
|
// Update
|
|
|
|
pkg.Description = packageDescription;
|
|
|
|
|
|
|
|
pkg.LatestCommit = commit;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// First version
|
|
|
|
// First version
|
|
|
|
pkg = new Data.Packages.Package
|
|
|
|
pkg = new Package
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Id = pkgId,
|
|
|
|
Id = pkgId,
|
|
|
|
Description = packageDescription,
|
|
|
|
|
|
|
|
OwnerId = ownerId,
|
|
|
|
OwnerId = ownerId,
|
|
|
|
LatestCommit = commit
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
dbContext.Packages.Add(pkg);
|
|
|
|
dbContext.Packages.Add(pkg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pkg.Public = true;
|
|
|
|
|
|
|
|
pkg.LatestCommit = commit;
|
|
|
|
|
|
|
|
pkg.Description = packageDescription;
|
|
|
|
|
|
|
|
|
|
|
|
// here, the package is or new, or owned by the key owner
|
|
|
|
// here, the package is or new, or owned by the key owner
|
|
|
|
if (!packageIdPathInfo.Exists) packageIdPathInfo.Create();
|
|
|
|
if (!packageIdPathInfo.Exists) packageIdPathInfo.Create();
|
|
|
@ -437,7 +427,6 @@ namespace isnd.Services
|
|
|
|
}
|
|
|
|
}
|
|
|
|
string versionFullString = nugetVersion.ToFullString();
|
|
|
|
string versionFullString = nugetVersion.ToFullString();
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME default package type or null
|
|
|
|
|
|
|
|
dbContext.PackageVersions.Add
|
|
|
|
dbContext.PackageVersions.Add
|
|
|
|
(version = new PackageVersion
|
|
|
|
(version = new PackageVersion
|
|
|
|
{
|
|
|
|
{
|
|
|
|