[ArPow] Add templating repo to arpow tarball (#11055)

This commit is contained in:
Michael Simons 2021-07-07 11:27:27 -05:00 committed by GitHub
parent ef74b6ca71
commit 229bc924ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 111 additions and 34 deletions

View file

@ -11,6 +11,11 @@
<Sha>1968a003d845d119a9d38ac4daaeea22897f7daf</Sha>
<SourceBuild RepoName="symreader" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.DotNet.Common.ItemTemplates" Version="6.0.100-preview.7.21329.1" CoherentParentDependency="Microsoft.NET.Sdk">
<Uri>https://github.com/dotnet/templating</Uri>
<Sha>3bc0d90f3e450f3e4ebda128081d091fb42968e3</Sha>
<SourceBuild RepoName="templating" ManagedOnly="true" />
</Dependency>
<Dependency Name="Microsoft.DotNet.Test.ProjectTemplates.6.0" Version="1.0.2-beta4.21321.1">
<Uri>https://github.com/dotnet/test-templates</Uri>
<Sha>6898c1c70c2d14e9725ddab6e1ebe8084c4d7e27</Sha>

View file

@ -0,0 +1,99 @@
From 3ac6d94eed6cfbb7c06128fe4caa91e9701bc2f9 Mon Sep 17 00:00:00 2001
From: Vlada Shubina <vshubina@microsoft.com>
Date: Wed, 7 Jul 2021 12:10:50 +0300
Subject: [PATCH] fixed TemplateLocalizer tool
See https://github.com/dotnet/templating/issues/3379 for additional details.
---
NuGet.config | 1 +
.../TemplateLocalizer.cs | 8 +++++++-
.../Commands/Export/ExportCommand.cs | 8 ++------
.../ExportCommandTests.cs | 5 +++--
4 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/NuGet.config b/NuGet.config
index b91f5fa3..30266b54 100644
--- a/NuGet.config
+++ b/NuGet.config
@@ -9,6 +9,7 @@
<add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
<add key="nugetbuild" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/nuget-build/nuget/v3/index.json" />
<add key="dotnet-public" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json" />
+ <add key="dotnet-libraries" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-libraries/nuget/v3/index.json" />
</packageSources>
<disabledPackageSources />
</configuration>
diff --git a/src/Microsoft.TemplateEngine.TemplateLocalizer.Core/TemplateLocalizer.cs b/src/Microsoft.TemplateEngine.TemplateLocalizer.Core/TemplateLocalizer.cs
index f99ab340..ca64813e 100644
--- a/src/Microsoft.TemplateEngine.TemplateLocalizer.Core/TemplateLocalizer.cs
+++ b/src/Microsoft.TemplateEngine.TemplateLocalizer.Core/TemplateLocalizer.cs
@@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
@@ -48,11 +49,16 @@ public async Task<ExportResult> ExportLocalizationFilesAsync(string templateJson
IReadOnlyList<TemplateString> templateJsonStrings = stringExtractor.ExtractStrings(out string templateJsonLanguage);
string targetDirectory = options.TargetDirectory ?? Path.Combine(Path.GetDirectoryName(templateJsonPath) ?? string.Empty, "localize");
+ IEnumerable<string> languages = ExportOptions.DefaultLanguages;
+ if (options.Languages?.Any() ?? false)
+ {
+ languages = options.Languages;
+ }
await TemplateStringUpdater.UpdateStringsAsync(
templateJsonStrings,
templateJsonLanguage,
- options.Languages ?? ExportOptions.DefaultLanguages,
+ languages,
targetDirectory,
options.DryRun,
_logger,
diff --git a/src/Microsoft.TemplateEngine.TemplateLocalizer/Commands/Export/ExportCommand.cs b/src/Microsoft.TemplateEngine.TemplateLocalizer/Commands/Export/ExportCommand.cs
index 5466ddcb..e1d8df4b 100644
--- a/src/Microsoft.TemplateEngine.TemplateLocalizer/Commands/Export/ExportCommand.cs
+++ b/src/Microsoft.TemplateEngine.TemplateLocalizer/Commands/Export/ExportCommand.cs
@@ -33,15 +33,11 @@ public override Command CreateCommand()
Name = "--recursive",
Description = LocalizableStrings.command_export_help_recursive_description,
});
- exportCommand.AddOption(new Option("-l")
+ exportCommand.AddOption(new Option<string>("-l")
{
Name = "--language",
Description = LocalizableStrings.command_export_help_language_description,
- Argument = new Argument()
- {
- Arity = ArgumentArity.OneOrMore,
- ArgumentType = typeof(string),
- },
+ Arity = ArgumentArity.OneOrMore
});
exportCommand.AddOption(new Option("-d")
{
diff --git a/test/Microsoft.TemplateEngine.TemplateLocalizer.IntegrationTests/ExportCommandTests.cs b/test/Microsoft.TemplateEngine.TemplateLocalizer.IntegrationTests/ExportCommandTests.cs
index 15682740..db81413c 100644
--- a/test/Microsoft.TemplateEngine.TemplateLocalizer.IntegrationTests/ExportCommandTests.cs
+++ b/test/Microsoft.TemplateEngine.TemplateLocalizer.IntegrationTests/ExportCommandTests.cs
@@ -153,11 +153,12 @@ public async Task LanguagesCanBeOverriden()
string[] exportedFiles = await RunTemplateLocalizer(
GetTestTemplateJsonContent(),
_workingDirectory,
- args: new string[] { "export", _workingDirectory, "--language", "tr" })
+ args: new string[] { "export", _workingDirectory, "--language", "tr", "de" })
.ConfigureAwait(false);
- Assert.Single(exportedFiles);
+ Assert.Equal(2, exportedFiles.Length);
Assert.True(File.Exists(Path.Combine(_workingDirectory, "localize", "templatestrings.tr.json")));
+ Assert.True(File.Exists(Path.Combine(_workingDirectory, "localize", "templatestrings.de.json")));
Assert.False(File.Exists(Path.Combine(_workingDirectory, "localize", "templatestrings.es.json")));
}
--
2.29.2

View file

@ -42,6 +42,7 @@
<!-- Tier 2 -->
<RepositoryReference Include="linker" />
<RepositoryReference Include="templating" />
<!-- Package source-build artifacts -->
<RepositoryReference Include="package-source-build" />

View file

@ -2,52 +2,24 @@
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup>
<ShippingPackagesOutput>$(ProjectDirectory)artifacts/packages/$(Configuration)/Shipping/</ShippingPackagesOutput>
<NonShippingPackagesOutput>$(ProjectDirectory)artifacts/packages/$(Configuration)/NonShipping/</NonShippingPackagesOutput>
<RepoApiImplemented>false</RepoApiImplemented>
<BuildCommandArgs>--restore --pack --configuration $(Configuration) $(OutputVersionArgs)</BuildCommandArgs>
<BuildCommandArgs>$(BuildCommandArgs) $(FlagParameterPrefix)warnasError $(ArcadeFalseBoolBuildArg)</BuildCommandArgs>
<BuildCommandArgs>$(BuildCommandArgs) /p:PackSpecific=true</BuildCommandArgs>
<BuildCommandArgs>$(BuildCommandArgs) /p:UseAppHost=false</BuildCommandArgs>
<LogVerbosityOptOut>true</LogVerbosityOptOut>
<BuildCommandArgs>$(BuildCommandArgs) -v $(LogVerbosity)</BuildCommandArgs>
<BuildCommandArgs>$(BuildCommandArgs) -bl</BuildCommandArgs>
<BuildCommandArgs>$(BuildCommandArgs) --ci</BuildCommandArgs>
<BuildCommandArgs>$(StandardSourceBuildArgs) -v $(LogVerbosity)</BuildCommandArgs>
<BuildCommandArgs>$(BuildCommandArgs) $(FlagParameterPrefix)warnAsError $(ArcadeFalseBoolBuildArg)</BuildCommandArgs>
<BuildCommand>$(StandardSourceBuildCommand) $(BuildCommandArgs)</BuildCommand>
<!-- Pass in package version props using the Product Construction (ProdCon) API. -->
<BuildCommandArgs>$(BuildCommandArgs) /p:PB_PackageVersionPropsUrl=file:%2F%2F$(PackageVersionPropsPath)</BuildCommandArgs>
<BuildCommand>$(ProjectDirectory)\build$(ShellExtension) $(BuildCommandArgs)</BuildCommand>
<DependencyVersionInputRepoApiImplemented>true</DependencyVersionInputRepoApiImplemented>
<EnvironmentRestoreSources>$(SourceBuiltPackagesPath)</EnvironmentRestoreSources>
<EnvironmentRestoreSources Condition="'$(OfflineBuild)' == 'true'">$(EnvironmentRestoreSources)%3B$(ReferencePackagesDir)%3B$(PrebuiltPackagesPath)</EnvironmentRestoreSources>
<EnvironmentRestoreSources Condition="'$(OfflineBuild)' != 'true'">$(EnvironmentRestoreSources)%3Bhttps://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public%40Local/nuget/v3/index.json</EnvironmentRestoreSources>
<GlobalJsonFile>$(ProjectDirectory)global.json</GlobalJsonFile>
<NuGetConfigFile>$(ProjectDirectory)NuGet.config</NuGetConfigFile>
<OutputPlacementRepoApiImplemented>false</OutputPlacementRepoApiImplemented>
</PropertyGroup>
<ItemGroup>
<RepositoryReference Include="clicommandlineparser" />
<RepositoryReference Include="newtonsoft-json" />
<RepositoryReference Include="source-build" />
</ItemGroup>
<ItemGroup>
<UseSourceBuiltSdkOverride Include="@(ArcadeSdkOverride)" />
</ItemGroup>
<ItemGroup>
<EnvironmentVariables Include="RestoreSources=$(EnvironmentRestoreSources)" />
</ItemGroup>
<Target Name="SetOutputList" AfterTargets="Package" BeforeTargets="GatherBuiltPackages">
<ItemGroup>
<PackagesOutputList Include="$(ShippingPackagesOutput)" />
<PackagesOutputList Include="$(NonShippingPackagesOutput)" />
</ItemGroup>
</Target>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
</Project>