forked from tomchavakis/nuget-license
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parameter to select the type of output for version 3.0.0 (#142)
- Loading branch information
Showing
47 changed files
with
522 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,9 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v3 | ||
- name: Setup dotnet 6.0.x | ||
uses: actions/setup-dotnet@v1 | ||
uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: "6.0.x" # SDK Version to use (x uses the latest version). | ||
env: | ||
|
@@ -43,12 +43,12 @@ jobs: | |
run: dotnet pack -c Release -o ./artifacts | ||
# Zip Artifacts | ||
- name: Zip artifacts | ||
uses: tomchavakis/[email protected].0 | ||
uses: tomchavakis/[email protected].1 | ||
with: | ||
args: zip -qq -r ./release.zip ./artifacts | ||
- name: Create release | ||
id: create_release | ||
uses: actions/create-release@v1.0.0 | ||
uses: actions/create-release@v1.1.4 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"scanSettings": { | ||
"baseBranches": [] | ||
}, | ||
"checkRunSettings": { | ||
"vulnerableCheckRunConclusionLevel": "failure", | ||
"displayMode": "diff", | ||
"useMendCheckNames": true | ||
}, | ||
"issueSettings": { | ||
"minSeverityLevel": "LOW", | ||
"issueType": "DEPENDENCY" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"extends": [ | ||
"config:base" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using NuGetUtility.LicenseValidator; | ||
|
||
namespace NuGetUtility.Output | ||
{ | ||
public interface IOutputFormatter | ||
{ | ||
Task Write(Stream stream, IEnumerable<LicenseValidationError> errors); | ||
Task Write(Stream stream, IEnumerable<ValidatedLicense> validated); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using NuGetUtility.LicenseValidator; | ||
using System.Text.Json; | ||
|
||
namespace NuGetUtility.Output.Json | ||
{ | ||
public class JsonOutputFormatter : IOutputFormatter | ||
{ | ||
private readonly JsonSerializerOptions _options; | ||
public JsonOutputFormatter() | ||
{ | ||
_options = new JsonSerializerOptions | ||
{ | ||
Converters = { new NuGetVersionJsonConverter() } | ||
}; | ||
} | ||
|
||
public async Task Write(Stream stream, IEnumerable<LicenseValidationError> errors) | ||
{ | ||
await JsonSerializer.SerializeAsync(stream, errors, _options); | ||
} | ||
public async Task Write(Stream stream, IEnumerable<ValidatedLicense> validated) | ||
{ | ||
await JsonSerializer.SerializeAsync(stream, validated, _options); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using NuGet.Versioning; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace NuGetUtility.Output.Json | ||
{ | ||
public class NuGetVersionJsonConverter : JsonConverter<NuGetVersion> | ||
{ | ||
public override NuGetVersion? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
var readStringValue = reader.GetString(); | ||
return new NuGetVersion(readStringValue); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, NuGetVersion value, JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.ToString()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using NuGetUtility.LicenseValidator; | ||
|
||
namespace NuGetUtility.Output.Table | ||
{ | ||
public class TableOutputFormatter : IOutputFormatter | ||
{ | ||
public async Task Write(Stream stream, IEnumerable<LicenseValidationError> errors) | ||
{ | ||
await TablePrinterExtensions.Create(stream, "Context", "Package", "Version", "LicenseError") | ||
.FromValues(errors, | ||
error => | ||
{ | ||
return new object[] { error.Context, error.PackageId, error.PackageVersion, error.Message }; | ||
}) | ||
.Print(); | ||
} | ||
|
||
public async Task Write(Stream stream, IEnumerable<ValidatedLicense> validated) | ||
{ | ||
await TablePrinterExtensions | ||
.Create(stream, "Package", "Version", "License Information Origin", "License Expression") | ||
.FromValues( | ||
validated, | ||
license => | ||
{ | ||
return new object[] | ||
{ | ||
license.PackageId, license.PackageVersion, license.LicenseInformationOrigin, license.License | ||
}; | ||
}) | ||
.Print(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...onsoleUtilities/TablePrinterExtensions.cs → ...ty/Output/Table/TablePrinterExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace NuGetUtility | ||
{ | ||
public enum OutputType | ||
{ | ||
Table, | ||
Json | ||
} | ||
} |
Oops, something went wrong.