Skip to content

Commit

Permalink
Clean up generation and config
Browse files Browse the repository at this point in the history
  • Loading branch information
crobibero committed Feb 25, 2024
1 parent 8c9f7ae commit 846e9c5
Show file tree
Hide file tree
Showing 409 changed files with 82 additions and 3,337 deletions.
8 changes: 4 additions & 4 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@
"type": "string",
"enum": [
"CleanGenerated",
"CopyConfig",
"RestoreTools",
"Run"
"Run",
"UpdateConfig"
]
}
},
Expand All @@ -90,9 +90,9 @@
"type": "string",
"enum": [
"CleanGenerated",
"CopyConfig",
"RestoreTools",
"Run"
"Run",
"UpdateConfig"
]
}
},
Expand Down
47 changes: 29 additions & 18 deletions nuke/Generate.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
using System;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Nuke.Common;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tools.DotNet;
using Serilog;

public class Generate : NukeBuild
public partial class Generate : NukeBuild
{
static string[] IgnoreFiles =
const string StableOpenApi = """
"descriptionLocation": "https://repo.jellyfin.org/master/releases/openapi/jellyfin-openapi-stable.json"
""";

const string UnstableOpenApi = """
"descriptionLocation": "https://repo.jellyfin.org/master/releases/openapi/jellyfin-openapi-unstable.json"
""";

static readonly string[] _ignoreFiles =
[
".editorconfig",
"kiota-lock.json",
"kiota-lock-stable.json",
"kiota-lock-unstable.json"
"kiota-lock.json"
];


public static int Main () => Execute<Generate>(x => x.Run);

[Parameter("Configuration to build - 'Stable' (default) or 'Unstable'")]
Expand All @@ -33,7 +38,7 @@ public class Generate : NukeBuild

foreach (var file in generatedDirectory.GetFiles())
{
if (IgnoreFiles.Contains(file.Name, StringComparer.OrdinalIgnoreCase))
if (_ignoreFiles.Contains(file.Name, StringComparer.OrdinalIgnoreCase))
{
continue;
}
Expand All @@ -47,22 +52,23 @@ public class Generate : NukeBuild
}
});

Target CopyConfig => g => g
Target UpdateConfig => g => g
.DependsOn(RestoreTools, CleanGenerated)
.Executes(() =>
{
var sourceFile = Configuration == Configuration.Stable
? "kiota-lock-stable.json"
: "kiota-lock-unstable.json";
var sourcePath = Path.Combine(Solution.Jellyfin_Sdk.Directory, "Generated", sourceFile);
var destinationPath = Path.Combine(Solution.Jellyfin_Sdk.Directory, "Generated", "kiota-lock.json");

Log.Debug("Copying {0} to {1}", sourcePath, destinationPath);
File.Copy(sourcePath, destinationPath, overwrite: true);
var configPath = Path.Combine(Solution.Jellyfin_Sdk.Directory, "Generated", "kiota-lock.json");
var config = File.ReadAllText(configPath);

var desiredSpecification = Configuration == Configuration.Stable
? StableOpenApi
: UnstableOpenApi;

config = OpenApiRegex().Replace(config, desiredSpecification);
File.WriteAllText(configPath, config);
});

Target Run => g => g
.DependsOn(CopyConfig)
.DependsOn(UpdateConfig)
.Executes(() =>
{
DotNetTasks.DotNet(
Expand All @@ -85,4 +91,9 @@ public class Generate : NukeBuild
File.WriteAllText(file, contents);
}
});

[GeneratedRegex("""
"descriptionLocation": ".+"
""")]
private static partial Regex OpenApiRegex();
}
8 changes: 0 additions & 8 deletions src/Jellyfin.Sdk/Generated/Albums/AlbumsRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ public AlbumsItemRequestBuilder this[Guid position] { get {
urlTplParams.Add("Albums%2Did", position);
return new AlbumsItemRequestBuilder(urlTplParams, RequestAdapter);
} }
/// <summary>Gets an item from the Jellyfin.Sdk.Generated.Albums.item collection</summary>
/// <param name="position">The item id.</param>
[Obsolete("This indexer is deprecated and will be removed in the next major version. Use the one with the typed parameter instead.")]
public AlbumsItemRequestBuilder this[string position] { get {
var urlTplParams = new Dictionary<string, object>(PathParameters);
if (!string.IsNullOrWhiteSpace(position)) urlTplParams.Add("Albums%2Did", position);
return new AlbumsItemRequestBuilder(urlTplParams, RequestAdapter);
} }
/// <summary>
/// Instantiates a new AlbumsRequestBuilder and sets the default values.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,5 @@ public class InstantMixRequestBuilderGetQueryParameters {
[QueryParameter("userId")]
public Guid? UserId { get; set; }
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class InstantMixRequestBuilderGetRequestConfiguration : RequestConfiguration<InstantMixRequestBuilderGetQueryParameters> {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,5 @@ public class SimilarRequestBuilderGetQueryParameters {
[QueryParameter("userId")]
public Guid? UserId { get; set; }
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class SimilarRequestBuilderGetRequestConfiguration : RequestConfiguration<SimilarRequestBuilderGetQueryParameters> {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,5 @@ public class AlbumArtistsRequestBuilderGetQueryParameters {
public int?[] Years { get; set; }
#endif
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class AlbumArtistsRequestBuilderGetRequestConfiguration : RequestConfiguration<AlbumArtistsRequestBuilderGetQueryParameters> {
}
}
}
6 changes: 0 additions & 6 deletions src/Jellyfin.Sdk/Generated/Artists/ArtistsRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,5 @@ public class ArtistsRequestBuilderGetQueryParameters {
public int?[] Years { get; set; }
#endif
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class ArtistsRequestBuilderGetRequestConfiguration : RequestConfiguration<ArtistsRequestBuilderGetQueryParameters> {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,5 @@ public class InstantMixRequestBuilderGetQueryParameters {
[QueryParameter("userId")]
public Guid? UserId { get; set; }
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class InstantMixRequestBuilderGetRequestConfiguration : RequestConfiguration<InstantMixRequestBuilderGetQueryParameters> {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,5 @@ public class ArtistsItemRequestBuilderGetQueryParameters {
[QueryParameter("userId")]
public Guid? UserId { get; set; }
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class ArtistsItemRequestBuilderGetRequestConfiguration : RequestConfiguration<ArtistsItemRequestBuilderGetQueryParameters> {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,6 @@ public class WithImageIndexItemRequestBuilderGetQueryParameters {
public int? Width { get; set; }
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class WithImageIndexItemRequestBuilderGetRequestConfiguration : RequestConfiguration<WithImageIndexItemRequestBuilderGetQueryParameters> {
}
/// <summary>
/// Get artist image by name.
/// </summary>
public class WithImageIndexItemRequestBuilderHeadQueryParameters {
Expand Down Expand Up @@ -272,11 +266,5 @@ public class WithImageIndexItemRequestBuilderHeadQueryParameters {
[QueryParameter("width")]
public int? Width { get; set; }
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class WithImageIndexItemRequestBuilderHeadRequestConfiguration : RequestConfiguration<WithImageIndexItemRequestBuilderHeadQueryParameters> {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ public WithImageIndexItemRequestBuilder this[int position] { get {
urlTplParams.Add("imageIndex", position);
return new WithImageIndexItemRequestBuilder(urlTplParams, RequestAdapter);
} }
/// <summary>Gets an item from the Jellyfin.Sdk.Generated.Artists.item.Images.item.item collection</summary>
/// <param name="position">Image index.</param>
[Obsolete("This indexer is deprecated and will be removed in the next major version. Use the one with the typed parameter instead.")]
public WithImageIndexItemRequestBuilder this[string position] { get {
var urlTplParams = new Dictionary<string, object>(PathParameters);
if (!string.IsNullOrWhiteSpace(position)) urlTplParams.Add("imageIndex", position);
return new WithImageIndexItemRequestBuilder(urlTplParams, RequestAdapter);
} }
/// <summary>
/// Instantiates a new WithImageTypeItemRequestBuilder and sets the default values.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,5 @@ public class InstantMixRequestBuilderGetQueryParameters {
[QueryParameter("userId")]
public Guid? UserId { get; set; }
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class InstantMixRequestBuilderGetRequestConfiguration : RequestConfiguration<InstantMixRequestBuilderGetQueryParameters> {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,5 @@ public class SimilarRequestBuilderGetQueryParameters {
[QueryParameter("userId")]
public Guid? UserId { get; set; }
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class SimilarRequestBuilderGetRequestConfiguration : RequestConfiguration<SimilarRequestBuilderGetQueryParameters> {
}
}
}
8 changes: 0 additions & 8 deletions src/Jellyfin.Sdk/Generated/Audio/AudioRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ public WithItemItemRequestBuilder this[Guid position] { get {
urlTplParams.Add("itemId", position);
return new WithItemItemRequestBuilder(urlTplParams, RequestAdapter);
} }
/// <summary>Gets an item from the Jellyfin.Sdk.Generated.Audio.item collection</summary>
/// <param name="position">The item id.</param>
[Obsolete("This indexer is deprecated and will be removed in the next major version. Use the one with the typed parameter instead.")]
public WithItemItemRequestBuilder this[string position] { get {
var urlTplParams = new Dictionary<string, object>(PathParameters);
if (!string.IsNullOrWhiteSpace(position)) urlTplParams.Add("itemId", position);
return new WithItemItemRequestBuilder(urlTplParams, RequestAdapter);
} }
/// <summary>
/// Instantiates a new AudioRequestBuilder and sets the default values.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,5 @@ public RequestInformation ToGetRequestInformation(Action<RequestConfiguration<De
public StreamAacRequestBuilder WithUrl(string rawUrl) {
return new StreamAacRequestBuilder(rawUrl, RequestAdapter);
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class StreamAacRequestBuilderGetRequestConfiguration : RequestConfiguration<DefaultQueryParameters> {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,5 @@ public RequestInformation ToGetRequestInformation(Action<RequestConfiguration<De
public StreamMp3RequestBuilder WithUrl(string rawUrl) {
return new StreamMp3RequestBuilder(rawUrl, RequestAdapter);
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class StreamMp3RequestBuilderGetRequestConfiguration : RequestConfiguration<DefaultQueryParameters> {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,5 @@ public class WithSegmentIdWithContainerRequestBuilderGetQueryParameters {
[QueryParameter("width")]
public int? Width { get; set; }
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class WithSegmentIdWithContainerRequestBuilderGetRequestConfiguration : RequestConfiguration<WithSegmentIdWithContainerRequestBuilderGetQueryParameters> {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,5 @@ public class MainM3u8RequestBuilderGetQueryParameters {
[QueryParameter("width")]
public int? Width { get; set; }
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class MainM3u8RequestBuilderGetRequestConfiguration : RequestConfiguration<MainM3u8RequestBuilderGetQueryParameters> {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,6 @@ public class MasterM3u8RequestBuilderGetQueryParameters {
public int? Width { get; set; }
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class MasterM3u8RequestBuilderGetRequestConfiguration : RequestConfiguration<MasterM3u8RequestBuilderGetQueryParameters> {
}
/// <summary>
/// Gets an audio hls playlist stream.
/// </summary>
public class MasterM3u8RequestBuilderHeadQueryParameters {
Expand Down Expand Up @@ -643,11 +637,5 @@ public class MasterM3u8RequestBuilderHeadQueryParameters {
[QueryParameter("width")]
public int? Width { get; set; }
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class MasterM3u8RequestBuilderHeadRequestConfiguration : RequestConfiguration<MasterM3u8RequestBuilderHeadQueryParameters> {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,6 @@ public class StreamRequestBuilderGetQueryParameters {
public int? Width { get; set; }
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class StreamRequestBuilderGetRequestConfiguration : RequestConfiguration<StreamRequestBuilderGetQueryParameters> {
}
/// <summary>
/// Gets an audio stream.
/// </summary>
public class StreamRequestBuilderHeadQueryParameters {
Expand Down Expand Up @@ -651,11 +645,5 @@ public class StreamRequestBuilderHeadQueryParameters {
[QueryParameter("width")]
public int? Width { get; set; }
}
/// <summary>
/// Configuration for the request such as headers, query parameters, and middleware options.
/// </summary>
[Obsolete("This class is deprecated. Please use the generic RequestConfiguration class generated by the generator.")]
public class StreamRequestBuilderHeadRequestConfiguration : RequestConfiguration<StreamRequestBuilderHeadQueryParameters> {
}
}
}
Loading

0 comments on commit 846e9c5

Please sign in to comment.