Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: format code with dotnet-format, Prettier and StandardJS #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 70 additions & 70 deletions Tasks/DetermineIfPackageExists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,74 +18,74 @@ namespace NuGetPush.Tasks;

public class DetermineIfPackageExists() : NuGetPackageTaskBase
{
[Required]
public string PackagePath { get; set; }
[Output]
public bool PackageExists { get; private set; }
public string PackageId => PackagePath.GetPackageId();
public string PackageVersion => PackagePath.GetPackageVersion();
public NuGetVersion NuGetVersion => NuGetVersion.Parse(PackageVersion);
public override bool Execute()
{
try
{
return ValidateParameters();
}
catch (Exception ex)
{
Log.LogErrorFromException(ex);
return false;
}
}
public virtual bool DoesPackageExist()
{
try
{
var psi = new ProcessStartInfo("nuget", ["search", "-s", Source, PackageId, "-PreRelease"])
{
RedirectStandardOutput = true
};
var ps = Process.Start(psi);
ps.WaitForExit();
return !ps.StandardOutput.EndOfStream;
// TODO: Make this work with the NuGet API
// // Get the package metadata resource from the repository
// var resource = await Repository.GetResourceAsync<PackageMetadataResource>();
// // Find all versions of the package
// var packageMetadata = await resource.GetMetadataAsync(
// PackageId,
// true,
// true,
// new SourceCacheContext(),
// Logger,
// CancellationToken.None
// );
// // Check if the specific version exists
// foreach (var metadata in packageMetadata.Select(metadata => metadata.Identity))
// {
// if (
// metadata.Id.Equals(PackageId, OrdinalIgnoreCase)
// && metadata.Version == NuGetVersion
// )
// {
// return true;
// }
// }
}
catch (Exception ex)
{
Log.LogErrorFromException(ex);
}
return false;
}
[Required]
public string PackagePath { get; set; }

[Output]
public bool PackageExists { get; private set; }

public string PackageId => PackagePath.GetPackageId();

public string PackageVersion => PackagePath.GetPackageVersion();

public NuGetVersion NuGetVersion => NuGetVersion.Parse(PackageVersion);

public override bool Execute()
{
try
{
return ValidateParameters();
}
catch (Exception ex)
{
Log.LogErrorFromException(ex);
return false;
}
}

public virtual bool DoesPackageExist()
{
try
{
var psi = new ProcessStartInfo("nuget", ["search", "-s", Source, PackageId, "-PreRelease"])
{
RedirectStandardOutput = true
};
var ps = Process.Start(psi);
ps.WaitForExit();
return !ps.StandardOutput.EndOfStream;

// TODO: Make this work with the NuGet API
// // Get the package metadata resource from the repository
// var resource = await Repository.GetResourceAsync<PackageMetadataResource>();

// // Find all versions of the package
// var packageMetadata = await resource.GetMetadataAsync(
// PackageId,
// true,
// true,
// new SourceCacheContext(),
// Logger,
// CancellationToken.None
// );

// // Check if the specific version exists
// foreach (var metadata in packageMetadata.Select(metadata => metadata.Identity))
// {
// if (
// metadata.Id.Equals(PackageId, OrdinalIgnoreCase)
// && metadata.Version == NuGetVersion
// )
// {
// return true;
// }
// }
}
catch (Exception ex)
{
Log.LogErrorFromException(ex);
}

return false;
}
}
Loading
Loading