diff --git a/src/isnd/Controllers/Packages/PackagesController.GetPackage.cs b/src/isnd/Controllers/Packages/PackagesController.GetPackage.cs index 5847662..6c18f77 100644 --- a/src/isnd/Controllers/Packages/PackagesController.GetPackage.cs +++ b/src/isnd/Controllers/Packages/PackagesController.GetPackage.cs @@ -29,6 +29,9 @@ namespace isnd.Controllers s=>s.Name==version); var pkgNameSpec=$"{id}-{version}.{Constants.PacketFileExtension}"; + if (pkgVersionDirInfo == null) + return NotFound(); + FileInfo pkgFileInfo = pkgVersionDirInfo.GetFiles() .FirstOrDefault(p=>string.Compare(p.Name,pkgNameSpec, System.StringComparison.InvariantCultureIgnoreCase)==0); diff --git a/src/isnd/Controllers/Packages/PackagesController.GetVersions.cs b/src/isnd/Controllers/Packages/PackagesController.GetVersions.cs index f766b50..386689b 100644 --- a/src/isnd/Controllers/Packages/PackagesController.GetVersions.cs +++ b/src/isnd/Controllers/Packages/PackagesController.GetVersions.cs @@ -12,7 +12,7 @@ namespace isnd.Controllers public IActionResult GetVersions( string id, string version, - bool prerelease = false, + bool prerelease = true, string packageType = null, int skip = 0, int take = 50) diff --git a/src/isnd/Controllers/Packages/PackagesController.Put.cs b/src/isnd/Controllers/Packages/PackagesController.Put.cs index 5c0aaa4..c13bd38 100644 --- a/src/isnd/Controllers/Packages/PackagesController.Put.cs +++ b/src/isnd/Controllers/Packages/PackagesController.Put.cs @@ -8,6 +8,7 @@ using Microsoft.Extensions.Logging; using isnd.Entities; using Microsoft.AspNetCore.Http; using isn.abst; +using System.IO; namespace isnd.Controllers { @@ -35,8 +36,19 @@ namespace isnd.Controllers } foreach (IFormFile file in Request.Form.Files) { - var version = await packageManager.PutPackageAsync(file.OpenReadStream(), dbApiKey.UserId); - logger.LogInformation($"new package : {version.PackageId} {version.NugetLink}"); + FileInfo inputFileInfo = new FileInfo(file.Name); + switch (inputFileInfo.Extension) + { + case "nupkg": + case "nupkgs": + var libVersion = await packageManager.PutPackageAsync(inputFileInfo.Extension, file.OpenReadStream(), dbApiKey.UserId); + logger.LogInformation($"new package : {libVersion.PackageId} {libVersion.NugetLink}"); + break; + default: + logger.LogInformation($"file extension is not supported : {inputFileInfo.Extension}"); + break; + } + } return Ok(); } diff --git a/src/isnd/Controllers/Packages/PackagesController.Search.cs b/src/isnd/Controllers/Packages/PackagesController.Search.cs index 9406689..83e3a75 100644 --- a/src/isnd/Controllers/Packages/PackagesController.Search.cs +++ b/src/isnd/Controllers/Packages/PackagesController.Search.cs @@ -18,7 +18,7 @@ namespace isnd.Controllers string q=null, int skip=0, int take=25, - bool prerelease=false, + bool prerelease=true, string semVerLevel = "2.0.0", string packageType = "Dependency") { diff --git a/src/isnd/Interfaces/IPackageManager.cs b/src/isnd/Interfaces/IPackageManager.cs index fc79c6a..36ec1e8 100644 --- a/src/isnd/Interfaces/IPackageManager.cs +++ b/src/isnd/Interfaces/IPackageManager.cs @@ -30,7 +30,7 @@ namespace isnd.Interfaces Task SearchPackageAsync(PackageRegistrationQuery query); - Task PutPackageAsync(Stream packageStream, string ownerId); + Task PutPackageAsync(string fileExtension, Stream packageStream, string ownerId); } } \ No newline at end of file diff --git a/src/isnd/Services/PackageManager.cs b/src/isnd/Services/PackageManager.cs index 6b2a55c..8953266 100644 --- a/src/isnd/Services/PackageManager.cs +++ b/src/isnd/Services/PackageManager.cs @@ -396,7 +396,7 @@ namespace isnd.Services return new PackageSearchResult(packages, apiBase, count); } - public async Task PutPackageAsync(Stream packageStream, string ownerId) + public async Task PutPackageAsync(string fileExtension, Stream packageStream, string ownerId) { PackageVersion version = null; using (packageStream) @@ -441,7 +441,7 @@ namespace isnd.Services string packageIdPath = Path.Combine(isndSettings.PackagesRootDir, pkgId); pkgPath = Path.Combine(packageIdPath, nugetVersion.ToFullString()); - string name = $"{pkgId}-{nugetVersion}." + Constants.PacketFileExtension; + string name = $"{pkgId}-{nugetVersion}." + fileExtension; fullPath = Path.Combine(pkgPath, name); var authors = xMetaElements.FirstOrDefault(x => x.Name.LocalName == "authors")?.Value; diff --git a/src/isnd/Startup.cs b/src/isnd/Startup.cs index 6aeec10..3dce29e 100644 --- a/src/isnd/Startup.cs +++ b/src/isnd/Startup.cs @@ -52,7 +52,10 @@ namespace isnd .Configure(adminStartupListConf) .Configure(o => o.Path = "~/migrate") .AddDbContext(options => - options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"))) + options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection")) + .ConfigureWarnings(w => w.Ignore(RelationalEventId.PendingModelChangesWarning)) + .EnableDetailedErrors() + ) .AddIdentity() .AddRoles() .AddEntityFrameworkStores( @@ -96,7 +99,7 @@ namespace isnd s.SerializerSettings.ReferenceResolverProvider = () => new NSJWebApiReferenceResolver(); }) .AddXmlSerializerFormatters(); - #if SWAGGER +#if SWAGGER services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new OpenApiInfo @@ -119,7 +122,7 @@ namespace isnd var xmlFilename = $"{typeof(Startup).Assembly.GetName().Name}.xml"; options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename)); }); - #endif +#endif } @@ -134,10 +137,10 @@ namespace isnd { app.UseDeveloperExceptionPage(); app.UseMigrationsEndPoint(); - #if SWAGGER +#if SWAGGER app.UseSwagger(); app.UseSwaggerUI(); - #endif +#endif } else { diff --git a/src/isnd/appsettings.json b/src/isnd/appsettings.json index 1a0f421..9b3f99d 100644 --- a/src/isnd/appsettings.json +++ b/src/isnd/appsettings.json @@ -18,11 +18,6 @@ "SenderName": "", "SenderEmail": "" }, - "Unleash": - { - "ClientApiKey": "lame-unleash-client-api-key", - "ApiUrl": "http://localhost:4242/api/" - }, "Logging": { "LogLevel": { "Default": "Warning" diff --git a/test/data/test-isn/test-isn.csproj b/test/data/test-isn/test-isn.csproj index bcad69b..dfe7449 100644 --- a/test/data/test-isn/test-isn.csproj +++ b/test/data/test-isn/test-isn.csproj @@ -11,11 +11,4 @@ 1.0.7 - - - - - - -