|
|
@ -28,30 +28,29 @@ namespace isn.Controllers
|
|
|
|
|
|
|
|
|
|
|
|
const string _pkgRootPrefix = "~/package";
|
|
|
|
const string _pkgRootPrefix = "~/package";
|
|
|
|
const string defaultSemVer = "2.0.0";
|
|
|
|
const string defaultSemVer = "2.0.0";
|
|
|
|
private readonly Resource[] ressources;
|
|
|
|
private readonly Resource[] _ressources;
|
|
|
|
private readonly ILogger<PackagesController> logger;
|
|
|
|
private readonly ILogger<PackagesController> _logger;
|
|
|
|
private readonly IDataProtector protector;
|
|
|
|
private readonly IDataProtector _protector;
|
|
|
|
|
|
|
|
|
|
|
|
private readonly NugetSettings nugetSettings;
|
|
|
|
private readonly NugetSettings _nugetSettings;
|
|
|
|
readonly ApplicationDbContext dbContext;
|
|
|
|
readonly ApplicationDbContext _dbContext;
|
|
|
|
private readonly PackageManager packageManager;
|
|
|
|
private readonly PackageManager _packageManager;
|
|
|
|
private readonly IUnleash _unleashĈlient;
|
|
|
|
private readonly IUnleash _unleashĈlient;
|
|
|
|
|
|
|
|
|
|
|
|
public PackagesController(
|
|
|
|
public PackagesController(
|
|
|
|
PackageManager packageManager,
|
|
|
|
|
|
|
|
ILoggerFactory loggerFactory,
|
|
|
|
ILoggerFactory loggerFactory,
|
|
|
|
IDataProtectionProvider provider,
|
|
|
|
IDataProtectionProvider provider,
|
|
|
|
IOptions<NugetSettings> nugetOptions,
|
|
|
|
IOptions<NugetSettings> nugetOptions,
|
|
|
|
IUnleash unleashĈlient,
|
|
|
|
IUnleash unleashĈlient,
|
|
|
|
ApplicationDbContext dbContext)
|
|
|
|
ApplicationDbContext dbContext)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
logger = loggerFactory.CreateLogger<PackagesController>();
|
|
|
|
_logger = loggerFactory.CreateLogger<PackagesController>();
|
|
|
|
nugetSettings = nugetOptions.Value;
|
|
|
|
_nugetSettings = nugetOptions.Value;
|
|
|
|
protector = provider.CreateProtector(nugetSettings.ProtectionTitle);
|
|
|
|
_protector = provider.CreateProtector(_nugetSettings.ProtectionTitle);
|
|
|
|
this.dbContext = dbContext;
|
|
|
|
_dbContext = dbContext;
|
|
|
|
this.packageManager = packageManager;
|
|
|
|
_packageManager = new PackageManager(dbContext);
|
|
|
|
_unleashĈlient = unleashĈlient;
|
|
|
|
_unleashĈlient = unleashĈlient;
|
|
|
|
ressources = packageManager.GetResources(_unleashĈlient).ToArray();
|
|
|
|
_ressources = _packageManager.GetResources(_unleashĈlient).ToArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// dotnet add . package -s http://localhost:5000/packages isn
|
|
|
|
// dotnet add . package -s http://localhost:5000/packages isn
|
|
|
@ -64,7 +63,7 @@ namespace isn.Controllers
|
|
|
|
[HttpGet("~/index.json")]
|
|
|
|
[HttpGet("~/index.json")]
|
|
|
|
public IActionResult ApiIndex()
|
|
|
|
public IActionResult ApiIndex()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Ok(ressources);
|
|
|
|
return Ok(_ressources);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -91,7 +90,7 @@ namespace isn.Controllers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
if (ModelState.IsValid)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return Ok(packageManager.SearchByName(q,skip,take,prerelease,packageType));
|
|
|
|
return Ok(_packageManager.SearchByName(q,skip,take,prerelease,packageType));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return BadRequest(new { error = ModelState });
|
|
|
|
return BadRequest(new { error = ModelState });
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -116,7 +115,7 @@ namespace isn.Controllers
|
|
|
|
ModelState.AddModelError("semVerLevel", defaultSemVer + " expected");
|
|
|
|
ModelState.AddModelError("semVerLevel", defaultSemVer + " expected");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Ok(packageManager.AutoComplete(id,skip,take,prerelease,packageType));
|
|
|
|
return Ok(_packageManager.AutoComplete(id,skip,take,prerelease,packageType));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO GET {@id}/{LOWER_ID}/index.json
|
|
|
|
// TODO GET {@id}/{LOWER_ID}/index.json
|
|
|
|
// LOWER_ID URL string yes The package ID, lowercased
|
|
|
|
// LOWER_ID URL string yes The package ID, lowercased
|
|
|
@ -145,7 +144,7 @@ namespace isn.Controllers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Ok(new
|
|
|
|
return Ok(new
|
|
|
|
{
|
|
|
|
{
|
|
|
|
versions = packageManager.GetVersions(
|
|
|
|
versions = _packageManager.GetVersions(
|
|
|
|
id, parsedVersion, prerelease, packageType, skip, take)
|
|
|
|
id, parsedVersion, prerelease, packageType, skip, take)
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -159,7 +158,7 @@ namespace isn.Controllers
|
|
|
|
[FromRoute] string id, [FromRoute] string lower,
|
|
|
|
[FromRoute] string id, [FromRoute] string lower,
|
|
|
|
[FromRoute] string idf, [FromRoute] string lowerf)
|
|
|
|
[FromRoute] string idf, [FromRoute] string lowerf)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var pkgpath = Path.Combine(nugetSettings.PackagesRootDir,
|
|
|
|
var pkgpath = Path.Combine(_nugetSettings.PackagesRootDir,
|
|
|
|
id, lower, $"{idf}.{lowerf}.nupkg"
|
|
|
|
id, lower, $"{idf}.{lowerf}.nupkg"
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
@ -176,7 +175,7 @@ namespace isn.Controllers
|
|
|
|
[FromRoute][SafeName][Required] string idf,
|
|
|
|
[FromRoute][SafeName][Required] string idf,
|
|
|
|
[FromRoute][SafeName][Required] string lowerf)
|
|
|
|
[FromRoute][SafeName][Required] string lowerf)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var pkgpath = Path.Combine(nugetSettings.PackagesRootDir,
|
|
|
|
var pkgpath = Path.Combine(_nugetSettings.PackagesRootDir,
|
|
|
|
id, lower, $"{idf}.{lowerf}.nuspec");
|
|
|
|
id, lower, $"{idf}.{lowerf}.nuspec");
|
|
|
|
|
|
|
|
|
|
|
|
FileInfo pkgfi = new FileInfo(pkgpath);
|
|
|
|
FileInfo pkgfi = new FileInfo(pkgpath);
|
|
|
|