Skip to content

Commit

Permalink
Updated package.
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed Oct 15, 2024
1 parent a14c0d6 commit 34ef6db
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 5 deletions.
1 change: 1 addition & 0 deletions RelaxVersioner.Core.Tests/RelaxVersioner.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="Verify.NUnit" Version="26.3.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion RelaxVersioner.Core/RelaxVersioner.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
<ItemGroup>
<PackageReference Include="GitReader" Version="1.8.0" />
<PackageReference Include="NamingFormatter" Version="2.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
<PackageReference Condition="'$(RV_BOOTSTRAP)' != 'True'"
Include="RelaxVersioner" Version="3.6.0" PrivateAssets="all" />
Include="RelaxVersioner" Version="3.7.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
86 changes: 86 additions & 0 deletions RelaxVersioner.Core/Writers/NpmReplaceProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
////////////////////////////////////////////////////////////////////////////////////////
//
// RelaxVersioner - Git tag/branch based, full-automatic version generator.
// Copyright (c) Kouji Matsui (@kozy_kekyo, @[email protected])
//
// Licensed under Apache-v2: https://opensource.org/licenses/Apache-2.0
//
////////////////////////////////////////////////////////////////////////////////////////

#nullable enable

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
using NamingFormatter;
using Newtonsoft.Json;

namespace RelaxVersioner.Writers;

internal sealed class NpmReplaceProvider : WriteProviderBase
{
public override string Language => "NPM";

public override void Write(
ProcessorContext context,
Dictionary<string, object?> keyValues,
DateTimeOffset generated)
{
void Replace(TextReader tr, TextWriter tw)
{
var jr = new JsonTextReader(tr);



while (true)
{
var line = tr.ReadLine();
if (line == null)
{
break;
}

var formattedLine = Named.Format(
CultureInfo.InvariantCulture,
line,
keyValues,
key => string.Empty,
new(context.BracketStart, context.BracketEnd));

tw.WriteLine(formattedLine);
}

tw.Flush();
}

if (!string.IsNullOrWhiteSpace(context.OutputPath))
{
if (context.IsDryRun)
{
return;
}

Processor.WriteSafeTransacted(
context.OutputPath,
stream =>
{
using var tr = context.ReplaceInputPath is { } rip ?
new StreamReader(rip, Encoding.UTF8, true) :
Console.In;
var tw = new StreamWriter(stream, Encoding.UTF8);

Replace(tr, tw);
});
}
else
{
using var tr = context.ReplaceInputPath is { } rip ?
new StreamReader(rip, Encoding.UTF8, true) :
Console.In;
Replace(tr, Console.Out);
}
}
}
2 changes: 1 addition & 1 deletion RelaxVersioner.Tasks/RelaxVersioner.Tasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
<PackageReference Condition="'$(RV_BOOTSTRAP)' != 'True'"
Include="RelaxVersioner" Version="3.6.0" PrivateAssets="all" />
Include="RelaxVersioner" Version="3.7.0" PrivateAssets="all" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion RelaxVersioner/RelaxVersioner.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" />
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
<PackageReference Condition="'$(RV_BOOTSTRAP)' != 'True'"
Include="RelaxVersioner" Version="3.6.0" PrivateAssets="all" />
Include="RelaxVersioner" Version="3.7.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions rv-cli/rv-cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
<ItemGroup>
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
<PackageReference Condition="'$(RV_BOOTSTRAP)' != 'True'"
Include="RelaxVersioner" Version="3.6.0" PrivateAssets="all" />
Include="RelaxVersioner" Version="3.7.0" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\RelaxVersioner.Core\RelaxVersioner.Core.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="..\Images\RelaxVersioner.100.png" Link="Images\RelaxVersioner.100.png" Pack="true" PackagePath="\" />
<None Include="..\Images\RelaxVersioner.100.png" Pack="true" PackagePath="" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 34ef6db

Please sign in to comment.